The Web framework for perfectionists with deadlines.

Overview

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'

    opened by fcurella 717
  • 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
    opened by codingjoe 136
  • #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".

    opened by chrisk12345 119
  • 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.

    opened by edevil 90
  • 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

    opened by olivierdalang 79
  • 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

    opened by knyghty 77
  • 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.

    opened by laymonage 76
  • Fixed #33308 -- Added support for psycopg version 3

    Fixed #33308 -- Added support for psycopg version 3

    What did I do? I took https://github.com/dvarrazzo/django-psycopg3-backend and blackified it + ported over most (all?) new commits. I am now opening this on GitHub to be able to nicely diff and start a discussion about whether we can support psycopg2 & 3 easiyl from the same codebase (I think we can).


    I (i.e. @felixxm) have the following plan to move this forward:

    • [x] merge #16245,
    • [x] squash commits,
    • [x] rebase,
    • [x] revert unnecessary changes, e.g.
      • [x] https://github.com/django/django/pull/15687#discussion_r1036784854
    • [x] merge more small cleanups:
      • #16345
      • #16346
      • #16347
      • #16351
      • #16352
      • #16353
      • #16362
      • #16363
      • #16368
      • #16371
      • 2f38f7b8f9bd65905dc6bec4f3e2a30b5da8e338
      • 1d90c9b1132482d446ca8375c151e894002c9e8d
      • db7bb3b64e469fbb5c79e7b5b2fcb890434aa60f
    • [x] push (or wait) for docs changes,
    • [x] move import changes to a separate PR:
      • 2ebfbd894e21e1656c1e1f32d98b8df7a32d3649
    • [x] make detailed review,
    • [x] push (or wait) for final edits,
    • [x] merge :tada:
    opened by apollo13 73
  • 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

    opened by schinckel 71
  • 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.

    opened by raphaelm 64
  • 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.

    opened by codingjoe 59
  • Refs #34041 -- Added aria-current=

    Refs #34041 -- Added aria-current="page" to breadcrumbs in admin.

    opened by farita1699 0
  • Fixed #34235 -- Added a `manifest_hash` attribute to `ManifestFilesMixin`.

    Fixed #34235 -- Added a `manifest_hash` attribute to `ManifestFilesMixin`.

    Adds a manifest_hash attribute to ManifestFilesMixin exposing a "hash" of the full manifest. This allows applications to determine when their static files have changed.

    opened by apollo13 1
  • Refs #16163 -- Used headers argument for RequestFactory and Client in tests.

    Refs #16163 -- Used headers argument for RequestFactory and Client in tests.

    Follow-up/clean-up of https://github.com/django/django/pull/16163 (ticket-34074)

    With help from https://github.com/adamchainz/django-upgrade/pull/305, but also manually fixing. Ping @adamchainz to see the result the current state of the django-upgrade PR through the 3 commits.

    We will squash all commits before merging, the 3 commits are for comprehension of the django-upgrade work :)

    opened by David-Wobrock 0
  • Refs #34180

    Refs #34180

    Fixed #34180 -- Wrote addition to docs to address a bug.

    Added an explanation about a bug that changes the active language in subsequent tests when the test language is by using a cookie or HTTP header

    opened by fnaimi66 0
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.

Mattéo 4 Nov 16, 2021
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

Sanic Community Organization 16.7k Jan 8, 2023
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

vibora.io 5.7k Jan 8, 2023
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

André Roth 32 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

The Pallets Projects 61.5k Jan 6, 2023
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

null 20.9k Jan 1, 2023
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

Sanic Community Organization 16.7k Dec 28, 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

Bottle Micro Web Framework 7.8k Dec 31, 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

Pylons Project 3.7k Dec 30, 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

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

Masonite 1.9k Jan 4, 2023
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

null 2k Dec 31, 2022
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

Emmett 796 Dec 26, 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

null 687 Nov 27, 2022
An easy-to-use high-performance asynchronous web framework.

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

Aber 264 Dec 31, 2022
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.

null 83 Sep 23, 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.

Adrien Delsalle 1 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. check parameters and generate API documents automatically. Flask Sugar是一个基于flask,pyddantic,类型注解的API框架, 可以检查参数并自动生成API文档

null 162 Dec 26, 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

Kavindu Santhusa 8 Jun 16, 2022
Dazzler is a Python async UI/Web framework built with aiohttp and react.

Dazzler is a Python async UI/Web framework built with aiohttp and react. Create dazzling fast pages with a layout of Python components and bindings to update from the backend.

Philippe Duval 17 Oct 18, 2022