The Web framework for perfectionists with deadlines.

Django

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out.

All documentation is in the "docs" directory and online at https://docs.djangoproject.com/en/stable/. If you're just getting started, here's how we recommend you read the docs:

  • First, read docs/intro/install.txt for instructions on installing Django.
  • Next, work through the tutorials in order (docs/intro/tutorial01.txt, docs/intro/tutorial02.txt, etc.).
  • If you want to set up an actual deployment server, read docs/howto/deployment/index.txt for instructions.
  • You'll probably want to read through the topical guides (in docs/topics) next; from there you can jump to the HOWTOs (in docs/howto) for specific problems, and check out the reference (docs/ref) for gory details.
  • See docs/README for instructions on building an HTML version of the docs.

Docs are updated rigorously. If you find any problems in the docs, or think they should be clarified in any way, please take 30 seconds to fill out a ticket here: https://code.djangoproject.com/newticket

To get more help:

To contribute to Django:

To run Django's test suite:

Supporting the Development of Django

Django's development depends on your contributions.

If you depend on Django, remember to support the Django Software Foundation: https://www.djangoproject.com/fundraising/

Comments
  • #22667 replaced occurrences of master/slave terminology with leader/follower

    #22667 replaced occurrences of master/slave terminology with leader/follower

    The docs and some tests contain references to a master/slave db configuration. While this terminology has been used for a long time, those terms may carry racially charged meanings to users. This patch replaces all occurrences of master and slave with 'leader' and 'follower'

  • Fixed #14370 -- Added select2 widget for related object fields in admin.

    Fixed #14370 -- Added select2 widget for related object fields in admin.

    Adds jQuery Select2 version 4 to support async select inputs including a search feature.

    I split the PR in two commits, one is vendoring select2, one contains my code.

    Links & Discussions

    • djangoproject#14370
    • https://groups.google.com/forum/#!topic/django-developers/tCNWnLP8jzM
    • https://groups.google.com/forum/#!topic/django-developers/Ip63Xqw01IA/discussion
    • https://groups.google.com/forum/#!topic/django-developers/jGgZngTq3Gw/discussion

    Changes:

    • ~~jQuery noConflict is set to false, jQuery itself does not get removed form global~~
    • ~~the new select2 widget is automatically used if the related object has a registered admin and defines search fields~~
    • only str representation is supported at this point
    • the search feature uses the same field as the model admin

    Todo:

    • [x] ~~Possible deprecation of raw_id field?~~
    • [x] Release note. (Which release?)
    • [x] Selenium integration tests
    • [x] widget tests
    • [x] pagingnator and page tests
    • [x] view tests
    • [x] admin_site integration tests
    • [x] add MODEL_change permission to json view
    • [x] system checks
  • #22707 Replaced misleading primary/replica terminology with widely recognized m...

    #22707 Replaced misleading primary/replica terminology with widely recognized m...

    ...aster/slave

    All occurences of "master/slave" were recently replaced with "leader/follower" (https://github.com/django/django/pull/2692), then with "primary/replica" (https://github.com/django/django/commit/beec05686ccc3bee8461f9a5a02c607a02352ae1). This new terminology is vague, ill-advised, and '''very misleading.'''

    Django is a server-side framework with the goal of making Pythonistas' life sweet. By no means this requires reforming old and widely accepted database terminology, or feeding fat internet trolls like Feminist Software Foundation.

    Let's look at the famous Zen of Python:

    • Special cases aren't special enough to break the rules.
    • Although practicality beats purity.
    • There should be one-- and preferably only one --obvious way to do it.

    And, above all:

    • '''Explicit is better than implicit.'''

    Here are four reasons, baked in the core of the language, as well as in the core or the developers' hearts, for why changing this '''old, clear, concise and immediately recognized''' terminology is a bad idea.

    This terminology has been used for a long time, and by no means those purely technical terms carry racially charged meanings to users, neither are they offending in any other way. This patch replaces all occurrences of "primary/replica" with the good old "master/slave" together with now unnecessary comments like "referred to as master/slave by some databases".

  • Fixed #21231 -- Enforced a max size for POST values read into memory

    Fixed #21231 -- Enforced a max size for POST values read into memory

    Enforce a maximum size for form field values read into memory. Based on https://github.com/django/django/pull/3020 and https://github.com/django/django/pull/2403.

  • Fixed #8936 -- Added view permissions and a read-only admin [rebased]

    Fixed #8936 -- Added view permissions and a read-only admin [rebased]

    Hi,

    This is just a rebase of https://github.com/django/django/pull/5297 The only difference (besides fixing the merge conflicts) is that ModelAdmin.declared_fieldsets doesn't exist anymore and was replaced by get_fieldsets.

    Thanks,

    Olivier

  • Fixed #31034 -- Added a navigation sidebar to the admin

    Fixed #31034 -- Added a navigation sidebar to the admin

    https://code.djangoproject.com/ticket/31034

    I'm not altogether sure about my approach here. This seems to be the way that is the least disruptive to me, (almost) all the CSS is in a new file so it shouldn't affect users that have it turned off.

    Really I think something like a drawer that slides from the side and covers some of the page would be better, as even with it only enabled on the largest breakpoint it can be a little crowded at the minimum size (1024px). Open to suggestions here. Also couldn't find a combination of heights and min-heights that would get the sidebar to cover the whole height of the screen without breaking something.

    I decided to default to on since it seems like the majority of users would want that, and it's easy enough to turn off if upgrading and not wanting it.

    Tested with latest Chrome, Firefox, Safari. Could use some eyes on other browsers.

    Will add tests/docs after getting some feedback.

    Screens:

    15" Macbook: Screenshot 2019-12-05 at 14 22 05

    At 1025px, the smallest size the sidebar will show up (a little crowded, but didn't want to add another breakpoint): Screenshot 2019-12-05 at 14 24 00

  • Fixed #12990 -- Added JSONField model field.

    Fixed #12990 -- Added JSONField model field.

    This pull request is closed. Please look at #12392 instead.


    Ticket #12990, as part of the Google Summer of Code program.

    Some points:

    • Currently supports storing and retrieving any valid JSON value (boolean, integer, float, string, object, array) on all supported database backends (SQLite, PostgreSQL, MySQL, MariaDB, Oracle). Note: Oracle only supports JSON object and array if IS JSON constraint is enabled.
    • Supports custom encoder and decoder (defaults to json.JSONEncoder and json.JSONDecoder, respectively). I had to cast the SELECT query to text for PostgreSQL to avoid having the value already decoded in from_db_value so it's possible to use a custom decoder (see psycopg2 docs).
    • Custom lookups and transforms from contrib.postgres.fields.JSONField are implemented as possibly supported for each backend.
    • Check constraints are applied.
      • MariaDB and SQLite have a JSON_VALID function which works well.
      • Oracle has IS JSON constraint, but from what I tried, it only returns true if the field's value is either a JSON object or array.
      • The constraint already comes with the JSON data types in PostgreSQL and MySQL. You can only insert valid JSON values for jsonb and json columns.
    • Oracle implementation uses the nclob data type. Oracle recommends using blob, but there are some downsides (see docs). Besides, an existing implementation of oracle-json-field uses clob. TextField also uses nclob, so I think this makes sense.
    • Needs JSON1 extension for SQLite. Most Linux distros already have it enabled by default in their SQLite and Python packages.
    • Supports introspection.

    More details of this available on my blog.

  • Fixed #27149 -- Added Subquery and Exists database expressions.

    Fixed #27149 -- Added Subquery and Exists database expressions.

    Sort-of related to:

    https://code.djangoproject.com/ticket/16603 https://code.djangoproject.com/ticket/25789

    but this is dealing with .annotate(), rather than .filter() methods on a queryset.

    https://code.djangoproject.com/ticket/27149

  • Refs #16859 -- Allowed storing CSRF tokens in sessions.

    Refs #16859 -- Allowed storing CSRF tokens in sessions.

    I'd love to have some review on this, but I'm fine with postponing the merge after Shai landed his changes to CSRF handling, as those two will get merge conflicts.

  • Refs #29444 -- Allowed returning multiple fields from INSERT statements on PostgreSQL.

    Refs #29444 -- Allowed returning multiple fields from INSERT statements on PostgreSQL.

    Ticket #29444

    Currently the PK is hardcoded as the only retuning object which is not necessary and currently blocking #27452.

    Side note:

    This change should be fully backwards compatible. I am aware that this fix allows adding database defaults to all backends but MySQL. This is why I want to keep this an undocumented API for now. People will find out about it anyways.

    You can implement a database default as follows:

    class Default:
        """
        Expression for ``DEFAULT``.
    
        In an insert query this will return the database default.
        """
    
        def as_sql(self, compiler, connection):
            return connection.ops.pk_default_value(), []
    
    
    class MyModel(models.Model):
        my_uuid_with_db_default = models.UUIDField(default=Default)
    

    If you have a default set for your column in the database, it will return that instead of trying to set null. You no longer need to call refresh_from_db or any other strange thing.

  • Fixed #30581 -- Added support for Meta.constraints validation.

    Fixed #30581 -- Added support for Meta.constraints validation.

    https://code.djangoproject.com/ticket/30581

    Still needed:

    • [x] Update Model.full_clean to take advantage of this new Constraint.validate
    • [x] Documentation
    • [x] More tests (Additional tests around exclude usage would also be appreciated.)

    About Model.full_clean, as it have a parameter validate_unique, should we still have a special case for UniqueConstraint, excluding them from Model.full_clean to only have them checked in Model.validate_unique?

  • Fixes #33697 Cleanup duplication of HTTP header parsing in utils.http and multipart parser

    Fixes #33697 Cleanup duplication of HTTP header parsing in utils.http and multipart parser

    Refactoring the duplicate of HTTP header parsing function that exists at django.utils.http and django/utils/http.py and Unifying the function under django.utils.http.

  • Update admin/change_form.html template

    Update admin/change_form.html template

    Display the app name capitalized in the add/change view breadcrumbs. This make breadcrumbs looking better, more uniform. Models' verbose names (plural) are filtered with capfirst as well.

  • Fixed #24638 -- Added support for SQL comments in queries.

    Fixed #24638 -- Added support for SQL comments in queries.

    Ticket 24638

    This PR tries to bring back life into this ticket which last stalled in https://github.com/django/django/pull/4495. I think it would be a useful addition to Django for adding traceability into stuff like logged slow queries.

    I stuck with using the C-style block comment delimiters (/**/) instead of the double-dash (--) as the later require a line break to mark the end of the comment and that felt off since to my knowledge we previously haven't output any line breaks in queries. The downside of using the block comments it that they are harder to sanitize but recursively stripping the delimiters using a regex should be sufficient.

    Except for sanitation of the input this PR changes so that the comments ends up at the end of the statement, it also allows chaining of comments. This aligns the behaviour with how Ruby on Rails does it. The sqlcommenter specification used for distributed tracing also expects comments at the end of the statement.

    Adding the comment at the end of the statement stops this method from being used to add optimizer hints on supporting databases but I think that should be treated as a separate ticket.

  • Swap `_rows_count` and `deleted` in `QuerySet.delete`.

    Swap `_rows_count` and `deleted` in `QuerySet.delete`.

    The doc says:

    The delete method, conveniently, is named [delete()](https://docs.djangoproject.com/en/4.0/ref/models/instances/#django.db.models.Model.delete). This method immediately deletes the object and returns the number of objects deleted and a dictionary with the number of deletions per object type. Example:
    
    >>> e.delete()
    (1, {'blog.Entry': 1})
    

    And if we check Collector.delete we will see:

    return sum(deleted_counter.values()), dict(deleted_counter)
    

    But in QuerySet.delete I see:

    deleted, _rows_count = collector.delete()
    
    # Clear the result cache, in case this QuerySet gets reused.
    self._result_cache = None
    return deleted, _rows_count
    

    So, we need to swap _rows_count and deleted. It won't change the logic, but will fix the code from misunderstanding.

Asita is a web application framework for python based on express-js framework.

Asita is a web application framework for python. It is designed to be easy to use and be more easy for javascript users to use python frameworks because it is based on express-js framework.

Nov 16, 2021
Async Python 3.6+ web server/framework | Build fast. Run fast.
Async Python 3.6+ web server/framework | Build fast. Run fast.

Sanic | Build fast. Run fast. Build Docs Package Support Stats Sanic is a Python 3.6+ web server and web framework that's written to go fast. It allow

May 16, 2022
Fast, asynchronous and elegant Python web framework.
Fast, asynchronous and elegant Python web framework.

Warning: This project is being completely re-written. If you're curious about the progress, reach me on Slack. Vibora is a fast, asynchronous and eleg

May 14, 2022
cirrina is an opinionated asynchronous web framework based on aiohttp
cirrina is an opinionated asynchronous web framework based on aiohttp

cirrina cirrina is an opinionated asynchronous web framework based on aiohttp. Features: HTTP Server Websocket Server JSON RPC Server Shared sessions

Mar 5, 2022
The Python micro framework for building web applications.

Flask Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to co

May 14, 2022
Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.

Tornado Web Server Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed. By using non-blocking ne

May 17, 2022
Async Python 3.6+ web server/framework | Build fast. Run fast.
Async Python 3.6+ web server/framework | Build fast. Run fast.

Sanic | Build fast. Run fast. Build Docs Package Support Stats Sanic is a Python 3.6+ web server and web framework that's written to go fast. It allow

May 20, 2022
bottle.py is a fast and simple micro-framework for python web-applications.

Bottle: Python Web Framework Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module a

May 18, 2022
Pyramid - A Python web framework

Pyramid Pyramid is a small, fast, down-to-earth, open source Python web framework. It makes real-world web application development and deployment more

May 21, 2022
The Modern And Developer Centric Python Web Framework. Be sure to read the documentation and join the Slack channel questions: http://slack.masoniteproject.com
The Modern And Developer Centric Python Web Framework. Be sure to read the documentation and join the Slack channel questions: http://slack.masoniteproject.com

NOTE: Masonite 2.3 is no longer compatible with the masonite-cli tool. Please uninstall that by running pip uninstall masonite-cli. If you do not unin

May 16, 2022
Free and open source full-stack enterprise framework for agile development of secure database-driven web-based applications, written and programmable in Python.

Readme web2py is a free open source full-stack framework for rapid development of fast, scalable, secure and portable database-driven web-based applic

May 20, 2022
The web framework for inventors
The web framework for inventors

Emmett is a full-stack Python web framework designed with simplicity in mind. The aim of Emmett is to be clearly understandable, easy to be learned an

May 16, 2022
A micro web-framework using asyncio coroutines and chained middleware.

Growler master ' dev Growler is a web framework built atop asyncio, the asynchronous library described in PEP 3156 and added to the standard library i

May 12, 2022
An easy-to-use high-performance asynchronous web framework.
An easy-to-use high-performance asynchronous web framework.

An easy-to-use high-performance asynchronous web framework.

May 16, 2022
Sierra is a lightweight Python framework for building and integrating web applications
Sierra is a lightweight Python framework for building and integrating web applications

A lightweight Python framework for building and Integrating Web Applications. Sierra is a Python3 library for building and integrating web applications with HTML and CSS using simple enough syntax. You can develop your web applications with Python, taking advantage of its functionalities and integrating them to the fullest.

May 14, 2022
FPS, fast pluggable server, is a framework designed to compose and run a web-server based on plugins.

FPS, fast pluggable server, is a framework designed to compose and run a web-server based on plugins. It is based on top of fastAPI, uvicorn, typer, and pluggy.

Nov 16, 2021
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.

Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints. check parameters and generate API documents automatically. Flask Sugar是一个基于flask,pyddantic,类型注解的API框架, 可以检查参数并自动生成API文档

May 14, 2022
Fast⚡, simple and light💡weight ASGI micro🔬 web🌏-framework for Python🐍.

NanoASGI Asynchronous Python Web Framework NanoASGI is a fast ⚡ , simple and light ?? weight ASGI micro ?? web ?? -framework for Python ?? . It is dis

Feb 22, 2022
An easy-to-use high-performance asynchronous web framework.
An easy-to-use high-performance asynchronous web framework.

中文 | English 一个易用的高性能异步 web 框架。 Index.py 文档 Index.py 实现了 ASGI3 接口,并使用 Radix Tree 进行路由查找。是最快的 Python web 框架之一。一切特性都服务于快速开发高性能的 Web 服务。 大量正确的类型注释 灵活且高效的

May 16, 2022