djangodocs.org

694 sections in Django 5.2 Search all versions →

Reference GEOS API Geometry ObjectsGEOSGeometry

PreparedGeometry objects are optimized for the contains, intersects, covers, crosses, disjoint, overlaps, touches and within operations. Refer to the Prepared Geometries documentation for more information. GEOSGeometry.srs : Returns a SpatialReference object corresponding to the SRID of the geometry or None.

dumpdata

Reference django-admin and manage.py Available commands

--format FORMAT Specifies the serialization format of the output. Defaults to JSON. Supported formats are listed in Serialization formats. --indent INDENT Specifies the number of indentation spaces to use in the output.

Methods of BoundField

Reference The Forms API More granular output

If no widget is specified, then the field’s default widget will be used. BoundField.css_classes(extra_classes=None)[source] : When you use Django’s rendering shortcuts, CSS classes are used to indicate required form fields or fields that contain errors.

Widget

Reference Widgets Base widget classes

classWidget(attrs=None)[source] : This abstract class cannot be rendered, but provides the basic attribute attrs. You may also implement or override the render() method on custom widgets.

MultiWidget

Reference Widgets Base widget classes

classMultiWidget(widgets,attrs=None)[source] : A widget that is composed of multiple widgets. MultiWidget works hand in hand with the MultiValueField.

DateField

Reference Model field reference Field types

If you want to be able to modify this field, set the following instead of auto_now_add=True: The default form widget for this field is a DateInput. The admin adds a JavaScript calendar, and a shortcut for “Today”.

FileField

Reference Model field reference Field types

See Managing files for details on how to provide this object. The default form widget for this field is a ClearableFileInput. Using a FileField or an ImageField (see below) in a model takes a few steps:

Arguments

Reference Model field reference Relationship fieldsManyToManyField

ForeignKey.limit_choices_to : Sets a limit to the available choices for this field when this field is rendered using a ModelForm or the admin (by default, all objects in the queryset are available to choose).

Field API reference

Reference Model field reference

classField[source] : Field is an abstract class that represents a database table column. Django uses fields to create the database table (db_type()), to map Python types to database (get_prep_value()) and vice-versa (from_db_value()).

Field API reference

Reference Model field reference

Fields often receive their values as a different type, either from serialization or from forms. `to_python(value)`[[source]](https://github.com/django/django/blob/stable/5.2.x/django/db/models/fields/__init__.py#L758) : Converts the value into the correct Python object. It acts as the reverse of [`value_to_string()`](#django.db.models.Field.value_to_string), and is also called in [`clean()`](instances.md#django.db.models.Model.clean).

extra()

Reference QuerySet API reference QuerySet APIMethods that return new QuerySets

where / tables You can define explicit SQL WHERE clauses — perhaps to perform non-explicit joins — by using where. You can manually add tables to the SQL FROM clause by using tables.

Methods

Reference Request and response objects FileResponse objects

HttpRequest.get_preferred_type(media_types)[source] : > New in Django 5.2. HttpRequest.accepts(mime_type)[source] : Returns True if the request’s Accept header matches the mime_type argument: HttpRequest.read(size=None)[source] HttpRequest.readline()[source] HttpRequest.readlines()[source]

Topic guide Using the Django authentication system Authentication in web requestsRedirecting unauthorized requests in class-based views

If your AUTH_USER_MODEL inherits from AbstractBaseUser or implements its own get_session_auth_hash() method, authenticated sessions will include the hash returned by this function. In the AbstractBaseUser case, this is an HMAC of the password field.

All authentication views

Topic guide Using the Django authentication system Authentication in web requestsAuthentication Views

logout_then_login(request,login_url=None)[source] : Logs a user out on POST requests, then redirects to the login page. classPasswordChangeView[source] : URL name: password_change classPasswordChangeDoneView[source] : URL name: password_change_done classPasswordResetView[source] : URL name: password_reset

Using class-based views

Topic guide Introduction to class-based views

… is worth noting that what your method returns is identical to what you return from a function-based view, namely some form of HttpResponse. This means that http shortcuts or TemplateResponse objects are valid to use inside a class-based view. While …

Topic guide Models FieldsRelationships

It doesn’t matter which model has the ManyToManyField, but you should only put it in one of the models – not both. Generally, ManyToManyField instances should go in the object that’s going to be edited on a form.