Django (web framework) explained

Screenshot Alt:The default Django page
Author:Adrian Holovaty, Simon Willison
Developer:Django Software Foundation[1]
Released:[2]
Programming Language:Python
Size:8.9 MB[3]
Genre:Web framework
License:3-clause BSD[4]

Django (; sometimes stylized as django)[5] is a free and open-source, Python-based web framework that runs on a web server. It follows the model–template–views (MTV) architectural pattern.[6] [7] It is maintained by the Django Software Foundation (DSF), an independent organization established in the US as a 501(c)(3) non-profit.

Django's primary goal is to ease the creation of complex, database-driven websites. The framework emphasizes reusability and "pluggability" of components, less code, low coupling, rapid development, and the principle of don't repeat yourself.[8] Python is used throughout, even for settings, files, and data models. Django also provides an optional administrative create, read, update and delete interface that is generated dynamically through introspection and configured via admin models.

Some well-known sites that use Django include Instagram,[9] Mozilla,[10] Disqus,[11] Bitbucket,[12] Nextdoor[13] and Clubhouse.[14]

History

Django was created in the autumn of 2003, when the web programmers at the Lawrence Journal-World newspaper, Adrian Holovaty and Simon Willison, began using Python to build applications. Jacob Kaplan-Moss was hired early in Django's development shortly before Simon Willison's internship ended.[15] It was released publicly under a BSD license in July 2005. The framework was named after guitarist Django Reinhardt.[16] Adrian Holovaty is a Romani jazz guitar player inspired in part by Reinhardt's music.[17]

In June 2008, it was announced that a newly formed Django Software Foundation (DSF) would maintain Django in the future.[18]

Features

Components

Despite having its own nomenclature, such as naming the callable objects generating the HTTP responses "views", the core Django framework can be seen as an MVC architecture. It consists of an object-relational mapper (ORM) that mediates between data models (defined as Python classes) and a relational database ("Model"), a system for processing HTTP requests with a web templating system ("View"), and a regular-expression-based URL dispatcher ("Controller").

Also included in the core framework are:

Bundled applications

The main Django distribution also bundles a number of applications in its "contrib" package, including:

Extensibility

Django's configuration system allows third party code to be plugged into a regular project, provided that it follows the reusable app[21] conventions. More than 5000 packages[22] are available to extend the framework's original behavior, providing solutions to issues the original tool didn't tackle: registration, search, API provision and consumption, CMS, etc.

This extensibility is, however, mitigated by internal components' dependencies. While the Django philosophy implies loose coupling,[23] the template filters and tags assume one engine implementation, and both the auth and admin bundled applications require the use of the internal ORM. None of these filters or bundled apps are mandatory to run a Django project, but reusable apps tend to depend on them, encouraging developers to keep using the official stack in order to benefit fully from the apps ecosystem.

Server arrangements

Django can be run in conjunction with Apache, Nginx using WSGI, Gunicorn, or Cherokee using flup (a Python module).[24] [25] Django also includes the ability to launch a FastCGI server, enabling use behind any web server which supports FastCGI, such as Lighttpd or Hiawatha. It is also possible to use other WSGI-compliant web servers.[26] Django officially supports five database backends: PostgreSQL, MySQL, MariaDB, SQLite, and Oracle.[27] Microsoft SQL Server can be used with django-mssql while similarly external backends exist for IBM Db2,[28] SQL Anywhere[29] and Firebird.[30] There is a fork named django-nonrel, which supports NoSQL databases, such as MongoDB and Google App Engine's Datastore.[31]

Django may also be run in conjunction with Python on any Java EE application server such as GlassFish or JBoss. In this case django-jython must be installed in order to provide JDBC drivers for database connectivity, which also can provide functionality to compile Django in to a .war suitable for deployment.[32]

Version history

The Django team will occasionally designate certain releases to be "long-term support" (LTS) releases.[33] LTS releases will get security and data loss fixes applied for a guaranteed period of time, typically 3+ years, regardless of the pace of releases afterwards.

VersionRelease date[34] End of mainstream supportEnd of extended supportNotes[35]
scope="row" [36]
scope="row" [37] "new-admin"
scope="row" [38] "magic removal"
scope="row" [39] "newforms", testing tools
scope="row" [40] API stability, decoupled admin, unicode
scope="row" [41] Aggregates, transaction based tests
scope="row" [42] Multiple db connections, CSRF, model validation
scope="row" [43] Class based views, staticfiles
scope="row" [44] Time zones, in browser testing, app templates.
scope="row" [45] Python 3 Support, configurable user model
scope="row" [46] Dedicated to Malcolm Tredinnick, db transaction management, connection pooling.
scope="row" [47] Migrations, application loading and configuration.
scope="row" [48] Native support for multiple template engines. Support ended on 1 April 2018
scope="row" [49] Automatic password validation. New styling for admin interface.
scope="row" [50] Full text search for PostgreSQL. New-style middleware.
scope="row" [51] Last version to support Python 2.7. Support ended on 1 April 2020
scope="row" [52] First Python 3-only release, Simplified URL routing syntax, Mobile friendly admin.
scope="row" [53] Model "view" permission.
scope="row" [54] Security release.
scope="row" [55] ASGI support
scope="row" [56] Asynchronous views and middleware
scope="row" [57] April 2024 Tracking many to many relationships, added support for Python 3.11
scope="row" [58] April 2023 Support for pytz is now deprecated and will be removed in Django 5.0.
scope="row" [59] April 2023December 2023 Asynchronous ORM interface, CSRF_COOKIE_MASKED setting, outputting a form, like <nowiki>{{ form }}</nowiki>
scope="row" [60] December 2023April 2026 Psycopg 3 support, ENGINE as django.db.backends.postgresql supports both libraries.
scope="row" August 2024April 2025
scope="row" [61] April 2025December 2025

DjangoCon

There is a semiannual conference for Django developers and users, named "DjangoCon", that has been held since September 2008. DjangoCon is held annually in Europe, in May or June;[62] while another is held in the United States in August or September, in various cities.[63] The 2012 DjangoCon took place in Washington, D.C., from September 3 to 8. 2013 DjangoCon was held in Chicago at the Hyatt Regency Hotel and the post-conference Sprints were hosted at Digital Bootcamp, computer training center.[64] The 2014 DjangoCon US returned to Portland, OR from August 30 to 6 September. The 2015 DjangoCon US was held in Austin, TX from September 6 to 11 at the AT&T Executive Center. The 2016 DjangoCon US was held in Philadelphia, PA at The Wharton School of the University of Pennsylvania from July 17 to 22.[65] The 2017 DjangoCon US was held in Spokane, WA;[66] in 2018 DjangoCon US was held in San Diego, CA.[67] DjangoCon US 2019 was held again in San Diego, CA from September 22 to 27. DjangoCon 2021 took place virtually and in 2022, DjangoCon US returned to San Diego from October 16 to 21. DjangoCon US 2023 was held from October 16 to 20 at the Durham, NC convention center and DjangoCon US 2024 is scheduled to return to Durham for September 22 to 27.[68] [69]

Django mini-conferences are usually held every year as part of the Australian Python Conference 'PyCon AU'.[70] Previously, these mini-conferences have been held in:

Django has spawned user groups and meetups around the world, the most notable group is the Django Girls organization, which began in Poland but now has had events in 91 countries.[71] [72] [73]

Ports to other languages

Programmers have ported Django's template engine design from Python to other languages, providing decent cross-platform support. Some of these options are more direct ports; others, though inspired by Django and retaining its concepts, take the liberty to deviate from Django's design:

CMSs based on Django Framework

Django as a framework is capable of building a complete CMS, however there are dedicated CMS projects which are built upon and extend the Django framework. Below is a list of a few of the more popular Django-based CMSs:

See also

Notes and References

  1. Web site: django/README . GitHub . 8 September 2020.
  2. Web site: Django FAQ . 27 March 2019.
  3. Web site: Django Download. 7 August 2020.
  4. Web site: django/LICENSE . GitHub . 8 September 2020.
  5. Web site: FAQ: General - Django documentation - Django. 30 April 2016.
  6. Web site: FAQ: General - Django documentation - Django. 30 April 2016.
  7. Book: Adrian Holovaty, Jacob Kaplan-Moss . The Django Book . Django follows this MVC pattern closely enough that it can be called an MVC framework . etal . 3 September 2013 . https://web.archive.org/web/20160902130823/http://www.djangobook.com/en/2.0/chapter05.html#the-mtv-or-mvc-development-pattern . 2 September 2016 . dead .
  8. Web site: Design Philosophies. Django. 18 March 2018.
  9. Web site: What Powers Instagram: Hundreds of Instances, Dozens of Technologies. Instagram Engineering.
  10. Web site: Python. Mozilla Developer Network. https://web.archive.org/web/20120208002537/https://developer.mozilla.org/en/Python#Use_of_Python_at_Mozilla. 30 April 2016. 8 February 2012.
  11. Web site: Scaling Django to 8 Billion Page Views. Matt. Robenolt. blog.disqus.com.
  12. Web site: DjangoSuccessStoryBitbucket – Django. 30 April 2016. https://web.archive.org/web/20160420214550/https://code.djangoproject.com/wiki/DjangoSuccessStoryBitbucket. 20 April 2016. dead.
  13. Web site: The anti-Facebook: one in four American neighborhoods are now using this private social network. The Verge. 18 August 2014 . 16 June 2016.
  14. Web site: Demi . Luke . Reining in the thundering herd ⛈ Getting to 80% CPU utilization with Django . Clubhouse Blog . 16 August 2021 . en . 15 August 2021.
  15. Web site: What is the history of the Django web framework? Why has it been described as "developed in a newsroom"?. Willison. Simon. Simon Willison . Quora . 18 October 2019.
  16. Web site: Introducing Django. 29 July 2018 . The Django Book . https://web.archive.org/web/20180729171111/https://djangobook.com/introducing-django/ . 29 July 2018. dead.
  17. Web site: Review: Adrian Holovaty's Playful and Precise 'Melodic Guitar Music'. Acoustic Guitar. 12 December 2023 . https://web.archive.org/web/20231230012044/https://acousticguitar.com/review-adrian-holovatys-playful-and-precise-melodic-guitar-music/. 30 December 2023.
  18. Web site: Announcing the Django Software Foundation - Weblog - Django. 30 April 2016.
  19. Web site: Security in Django . Django Project . 25 March 2013.
  20. Web site: Best Basic Security Practices (Especially with Django) . 2012 . 25 March 2013 . Socol, James.
  21. Web site: What is a reusable app? — django-reusable-app-docs 0.1.0 documentation. 30 April 2016.
  22. Web site: Django Packages API packages list . 17 April 2023.
  23. Web site: Design philosophies - Django documentation - Django. 30 April 2016. 4 March 2016. https://web.archive.org/web/20160304084102/https://docs.djangoproject.com/en/1.7/misc/design-philosophies/. dead.
  24. Web site: Django documentation of deployment. https://web.archive.org/web/20120111101846/https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#cherokee-setup. dead. 11 January 2012.
  25. Web site: Cherokee Web Server - Cookbook Setting up Django - Cherokee Documentation. 30 April 2016.
  26. https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/ How to use Django with Apache and mod_wsgi
  27. Web site: Django documentation. Django documentation . 9 June 2023 .
  28. Web site: GitHub - ibmdb/python-ibmdb: Automatically exported from code.google.com/p/ibm-db. ibmdb. GitHub. 30 April 2016.
  29. Web site: Google Code Archive - Long-term storage for Google Code Project Hosting.. 30 April 2016.
  30. Web site: GitHub - maxirobaina/django-firebird: Firebird SQL backend for django. maxirobaina. GitHub. 30 April 2016.
  31. Web site: Django non-rel. 30 April 2016.
  32. Web site: GitHub - beachmachine/django-jython: Database backends and extensions for Django development on top of Jython.. beachmachine. GitHub. 30 April 2016.
  33. Web site: Django's release process - Django documentation - Django. 30 April 2016.
  34. Web site: Download Django - Django. www.djangoproject.com.
  35. Web site: FAQ: Installation - Django documentation - Django. docs.djangoproject.com.
  36. https://www.djangoproject.com/weblog/2005/nov/16/firstrelease/ "Introducing Django 0.90"
  37. https://www.djangoproject.com/weblog/2006/jan/11/091/ "Django 0.91 released"
  38. https://www.djangoproject.com/weblog/2006/jul/29/095/ "Introducing Django 0.95"
  39. https://www.djangoproject.com/weblog/2007/mar/23/096/ "Announcing Django 0.96!"
  40. http://www.djangoproject.com/weblog/2008/sep/03/1/ "Django 1.0 released!"
  41. https://www.djangoproject.com/weblog/2009/jul/29/1-point-1/ "Django 1.1 released"
  42. https://www.djangoproject.com/weblog/2010/may/17/12/ "Django 1.2 released"
  43. https://www.djangoproject.com/weblog/2011/mar/23/13/ "Django 1.3 released"
  44. https://www.djangoproject.com/weblog/2012/mar/23/14/ "Django 1.4 released"
  45. https://www.djangoproject.com/weblog/2013/feb/26/15/ "Django 1.5 released"
  46. https://www.djangoproject.com/weblog/2013/nov/06/django-16-released/ "Django 1.6 released"
  47. https://www.djangoproject.com/weblog/2014/sep/02/release-17-final/ "Django 1.7 released"
  48. https://www.djangoproject.com/weblog/2015/apr/01/release-18-final/ "Django 1.8 released"
  49. https://www.djangoproject.com/weblog/2015/dec/01/django-19-released/ "Django 1.9 released"
  50. https://www.djangoproject.com/weblog/2016/aug/01/django-110-released/ "Django 1.10 released"
  51. https://www.djangoproject.com/weblog/2017/apr/04/django-111-released/ "Django 1.11 released"
  52. https://www.djangoproject.com/weblog/2017/dec/02/django-20-released/ "Django 2.0 released"
  53. https://www.djangoproject.com/weblog/2018/aug/01/django-21-released/ "Django 2.1 released"
  54. https://docs.djangoproject.com/en/dev/releases/2.2/ Django 2.2 release notes
  55. https://docs.djangoproject.com/en/dev/releases/3.0/ Django 3.0 release notes
  56. https://docs.djangoproject.com/en/dev/releases/3.1/ Django 3.1 release notes
  57. Web site: Django 3.2 release notes . 6 April 2021 . 7 June 2021.
  58. Web site: Django 4.0 release notes . 7 December 2021 . 4 August 2022.
  59. Web site: Django 4.1 release notes . 3 August 2022 . 4 August 2022.
  60. Web site: Django 4.2 release notes . 4 August 2022.
  61. Web site: Django 5.1 release notes . 7 August 2024 . 8 August 2024.
  62. http://lanyrd.com/series/djangocon-eu/ DjangoCon EU series
  63. http://lanyrd.com/series/djangocon-us/ DjangoCon US series
  64. Web site: DjangoCon . DjangoCon . dead . 29 July 2012 . https://web.archive.org/web/20120805042732/http://www.djangocon.us/ . 5 August 2012 .
  65. Web site: DjangoCon . DjangoCon . 1 December 2016.
  66. Web site: DjangoCon. DjangoCon .
  67. Web site: DjangoCon. DjangoCon .
  68. Web site: About DjangoCon US 2023. DjangoCon US. 2024-07-17.
  69. Web site: About DjangoCon US. DjangoCon US. 2024-07-17.
  70. http://djangocon.com.au/ DjangoCon AU
  71. Web site: Lawrence-born Django, which revolutionized website construction, celebrating its 10th anniversary. 18 October 2019. 9 July 2015. Lawrence Journal-World.
  72. Web site: Django Girls - start your journey with programming. 21 October 2019.
  73. Web site: Django groups. Meetup.
  74. Web site: – Liquid template language. Shopify. Liquid template language.
  75. Web site: Template::Swig - Perl interface to Django-inspired Swig templating engine. - metacpan.org. metacpan.org.
  76. Web site: Home - Twig - The flexible, fast, and secure PHP template engine. Symfony. twig.sensiolabs.org. 10 December 2014. 9 July 2017. https://web.archive.org/web/20170709023155/https://twig.sensiolabs.org/. dead.
  77. Web site: twigjs/twig.js. GitHub.
  78. Web site: Welcome - Jinja2 (The Python Template Engine). jinja.pocoo.org.
  79. Web site: erlydtl/erlydtl. GitHub.
  80. Web site: django CMS - Enterprise Content Management with Django - django CMS. 2020-11-11. www.django-cms.org.