djangodocs.org

706 sections in Django 6.0 Search all versions →

ModelAdmin methods

Reference The Django admin site ModelAdmin objects

ModelAdmin.save_related(request,form,formsets,change)[source] : The save_related method is given the HttpRequest, the parent ModelForm instance, the list of inline formsets and a boolean value based on whether the parent is being added or changed.

ModelAdmin methods

Reference The Django admin site ModelAdmin objects

ModelAdmin.has_delete_permission(request,obj=None) : Should return True if deleting obj is permitted, False otherwise.

InlineModelAdmin options

Reference The Django admin site InlineModelAdmin objects

InlineModelAdmin.max_num : This controls the maximum number of forms to show in the inline. This doesn’t directly correlate to the number of objects, but can if the value is small enough.

AdminSite attributes

Reference The Django admin site AdminSite objects

AdminSite.login_form : Subclass of AuthenticationForm that will be used by the admin site login view. AdminSite.logout_template : Path to a custom template that will be used by the admin site logout view. AdminSite.password_change_form : > New in Django 6.0.

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/6.0.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