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.
Reference
The Django admin site
ModelAdmin objects
ModelAdmin.has_delete_permission(request,obj=None) : Should return True if deleting obj is permitted, False otherwise.
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.
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.
Reference
django.contrib.auth
Authentication backends
classAllowAllUsersModelBackend[source] : Same as ModelBackend except that it doesn’t reject inactive users because user_can_authenticate() always returns True.
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.
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.
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.
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.
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.
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”.
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:
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).
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()).
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.1.x/django/db/models/fields/__init__.py#L753) : 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).
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.
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.
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
Topic guide
Using the Django authentication system
Authentication in web requestsAuthentication Views
classPasswordResetView[source] : URL name: password_reset
Topic guide
Introduction to class-based views
… Django uses to build class-based generic views are built for maximum flexibility, and as such have many hooks in the form of default method implementations and attributes that you are unlikely to be concerned with in the simplest use cases. …