Reference
Applications
app_name is the full name of the app, e.g. 'django.contrib.admin'. apps.get_model(app_label,model_name,require_ready=True) : Returns the Model with the given app_label and model_name. As a shortcut, this method also accepts a single argument in the form app_label.model_name. model_name is case-insensitive.
Reference
Class-based generic views - flattened index
classCreateView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context fields form_class [get_form_class()] http_method_names initial [get_initial()] model pk_url_kwarg prefix [get_prefix()] query_pk_and_slug queryset [get_queryset()] response_class [render_to_response()] slug_field [get_slug_field()] slug_url_kwarg success_url [get_success_url()] template_engine template_name [get_template_names()] template_name_field template_name_suffix Methods as_view() dispatch() form_invalid() form_valid() get() …
Reference
Class-based generic views - flattened index
classUpdateView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context fields form_class [get_form_class()] http_method_names initial [get_initial()] model pk_url_kwarg prefix [get_prefix()] query_pk_and_slug queryset [get_queryset()] response_class [render_to_response()] slug_field [get_slug_field()] slug_url_kwarg success_url [get_success_url()] template_engine template_name [get_template_names()] template_name_field template_name_suffix Methods as_view() dispatch() form_invalid() form_valid() get() …
Reference
The following views are described on this page and provide a foundation for editing content: django.views.generic.edit.FormView django.views.generic.edit.CreateView django.views.generic.edit.UpdateView django.views.generic.edit.DeleteView NOTE: The messages framework contains > SuccessMessageMixin, which > facilitates presenting messages about successful form submissions.
Reference
Generic editing views
If this view is fetched via GET, it will display a confirmation page that should contain a form that POSTs to the same URL. classdjango.views.generic.edit.BaseDeleteView : A base view for deleting an object instance.
Reference
Editing mixins
classdjango.views.generic.edit.ProcessFormView : A mixin that provides basic HTTP GET and POST workflow.
Reference
Clickjacking Protection
… use a view decorator that tells the middleware not to set the header: NOTE: If you want to submit a form or access a session cookie within a frame or > iframe, you may need to modify the CSRF_COOKIE_SAMESITE or …
Reference
Admin actions
For example, to make an action available only on the change form, set location to ActionLocation.CHANGE_FORM: To make an action available on both the change list and the change form: Notice that description and description_plural were provided.
Reference
The Django admin site
ModelAdmin.fieldsets : Set fieldsets to control the layout of admin “add” and “change” pages.
Reference
The Django admin site
ModelAdmin.formfield_overrides : This provides a quick-and-dirty way to override some of the Field options for use in the admin. formfield_overrides is a dictionary mapping a field class to a dict of arguments to pass to the field at construction time.
Reference
The Django admin site
WARNING: When overriding ModelAdmin.save_model() and > ModelAdmin.delete_model(), your code must save/delete the > object. They aren’t meant for veto purposes, rather they allow you to > perform extra operations.
Reference
The Django admin site
ModelAdmin.get_exclude(request,obj=None) : The get_exclude method is given the HttpRequest and the obj being edited (or None on an add form) and is expected to return a list of fields, as described in ModelAdmin.exclude.
Reference
The Django admin site
ModelAdmin.get_inline_instances(request,obj=None)[source] : The get_inline_instances method is given the HttpRequest and the obj being edited (or None on an add form) and is expected to return a list or tuple of InlineModelAdmin objects, as described below in the InlineModelAdmin section.
Reference
The Django admin site
ModelAdmin.get_form(request,obj=None,**kwargs)[source] : Returns a ModelForm class for use in the admin add and change views, see add_view() and change_view(). ModelAdmin.get_formsets_with_inlines(request,obj=None)[source] : Yields (FormSet, InlineModelAdmin) pairs for use in admin add and change views.
Reference
The Django admin site
ModelAdmin.get_changeform_initial_data(request)[source] : A hook for the initial data on admin change forms. By default, fields are given initial values from GET parameters. For instance, ?name=initial_value will set the name field’s initial value to be initial_value.
Reference
The Django admin site
This can be accomplished by using a Media inner class on your ModelAdmin: The staticfiles app prepends STATIC_URL (or MEDIA_URL if STATIC_URL is None) to any asset paths. The same rules apply as regular asset definitions on forms.
Reference
The Django admin site
Also, your own admin forms or widgets depending on django.jQuery must specify js=['admin/js/jquery.init.js', …] when declaring form media assets.
Reference
The Django admin site
After looking at change_form.html we determine that we only need to override the object-tools-items block. Therefore here is our new change_form.html : And that’s it!
Reference
GeoDjango Database API
… right hand side, a tuple of the raster and band index can be specified. This results in the following general form for lookups involving rasters (assuming the Elevation model used in the GeoDjango Model API): For example: On the left …
Reference
GeoDjango Forms API
BaseGeometryWidget.geom_type : The OpenGIS geometry type, generally set by the form field. BaseGeometryWidget.map_srid : SRID code used by the map (default is 4326).