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.
663 sections in Django 5.0 Search all versions →
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 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 Widgets Base widget classes
classWidget(attrs=None) : 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) : 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
classField : 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
When querying, [`get_db_prep_value()`](#django.db.models.Field.get_db_prep_value) and [`get_prep_value()`](#django.db.models.Field.get_prep_value) are used: `get_prep_value(value)` : `value` is the current value of the model’s attribute, and the method should return data in a format that has been prepared for use as a parameter in a query.
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.
Reference Request and response objects FileResponse objects
HttpRequest.auser() : > New in Django 5.0. HttpRequest.get_host() : Returns the originating host of the request using information from the HTTP_X_FORWARDED_HOST (if USE_X_FORWARDED_HOST is enabled) and HTTP_HOST headers, in that order.
Reference Request and response objects FileResponse objects
HttpRequest.get_signed_cookie(key,default=RAISE_ERROR,salt='',max_age=None) : Returns a cookie value for a signed cookie, or raises a django.core.signing.BadSignature exception if the signature is no longer valid.
Topic guide Customizing authentication in Django Substituting a custom User model
Django’s built-in forms and views make certain assumptions about the user model that they are working with. The following forms are compatible with any subclass of AbstractBaseUser: AuthenticationForm: Uses the username field specified by USERNAME_FIELD.
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) : Logs a user out on POST requests, then redirects to the login page. classPasswordChangeView : URL name: password_change classPasswordChangeDoneView : URL name: password_change_done classPasswordResetView : 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. …
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 Using mixins with class-based views Building up Django’s generic class-based views
The _detail part can be changed by setting template_name_suffix on a subclass to something else. (For instance, the generic edit views use _form for create and update views, and _confirm_delete for delete views.)
Topic guide Using mixins with class-based views
First, let’s look at a naive attempt to combine DetailView with FormMixin to enable us to POST a Django Form to the same URL as we’re displaying an object using DetailView.