Reference Model forms
ModelFormOptions.exclude : A tuple or list of model field names to be excluded from the form.
711 sections in Django dev Search all versions →
Reference Model forms
ModelFormOptions.exclude : A tuple or list of model field names to be excluded from the form.
Reference Model forms
ModelFormOptions.fields : A tuple or list of model field names to be included in the form. The value '__all__' can be used to specify that all fields should be included.
Reference Settings
Default: 100 The maximum number of files that may be received via POST in a multipart/form-data encoded request before a SuspiciousOperation (TooManyFiles) is raised. You can set this to None to disable the check.
Topic guide Working with forms
GET and POST are the only HTTP methods to use when dealing with forms.
Topic guide Creating forms from models
It is strongly recommended that you explicitly set all fields that should be edited in the form using the fields attribute.
Topic guide Security in Django
In a cross-site scripting attack, malicious code in the form of a client-side script is injected into another user’s web browser, where it will be executed.
FAQ FAQ: The admin
You’ve got several options. If you want to piggyback on top of an add/change form that Django automatically generates, you can attach arbitrary JavaScript modules to the page via the model’s class Admin js parameter.
How-to How to use Django’s CSRF protection
There are cases when CsrfViewMiddleware.process_view may not have run before your view is run - 404 and 500 handlers, for example - but you still need the CSRF token in a form. Solution: use requires_csrf_token()
How-to How to create custom model fields
All of Django’s fields (and when we say fields in this document, we always mean model fields and not form fields) are subclasses of django.db.models.Field.
How-to How to create custom model fields
It’s used during model migrations to tell Django how to take an instance of your new field and reduce it to a serialized form - in particular, what arguments to pass to __init__() to recreate it.
How-to How to create custom template tags and filters
django.template.Library.inclusion_tag() Another common type of template tag is the type that displays some data by rendering another template. For example, Django’s admin interface uses custom template tags to display the buttons along the bottom of the “add/change” form pages.
Internals
Django’s built-in components, such as the admin interface and default form rendering, should adhere to established accessibility standards and meet our own targets for supporting specific input devices and assistive technologies.
Internals Django Deprecation Timeline
The DjangoDivFormRenderer and Jinja2DivFormRenderer transitional form renderers will be removed. Support for passing positional arguments to BaseConstraint will be removed. request will be required in the signature of ModelAdmin.lookup_allowed() subclasses. The django.db.models.sql.datastructures.Join will no longer fallback to get_joining_columns().
Internals Django’s release process
Since version 1.0, and ending with Django 6.2, Django’s release numbering works as follows: Versions are numbered in the form A.B or A.B.C. A.B is the feature release version number. C is the patch release version number.
Internals Django’s release process
From Django 2.0, and ending with Django 6.2, version numbers use a loose form of semantic versioning such that each version following a long-term support release will bump to the next “dot zero” version.
Internals Django’s release process
Starting with Django 2028, Django’s release numbering works as follows: Versions are numbered in the form YYYY or YYYY.N. YYYY is the feature release version number, using the four-digit year of release, for example 2028.
Tutorial
We’re continuing the web-poll application and will focus on form processing and cutting down our code. NOTE: If you’re having trouble going through this tutorial, please head over to > the Getting Help section of the FAQ.
Reference Class-based generic views - flattened index
classFormView Attributes (with optional accessor): content_type extra_context form_class [get_form_class()] http_method_names initial [get_initial()] prefix [get_prefix()] response_class [render_to_response()] success_url [get_success_url()] template_engine template_name [get_template_names()] Methods as_view() dispatch() form_invalid() form_valid() get() get_context_data() get_form() get_form_kwargs() http_method_not_allowed() post() put() setup()
Reference Editing mixins
classdjango.views.generic.edit.FormMixin : A mixin class that provides facilities for creating and displaying forms.
Reference Admin actions
NOTE: Added in version 6.1. classActionLocation[source] : Enum of allowed values for the location parameter of the action() decorator.