Reference
The Django admin site
Not every template in contrib/admin/templates/admin may be overridden per app or per model. The following can: actions.html app_index.html change_form.html change_form_actions.html change_form_object_tools.html change_list.html change_list_object_tools.html change_list_results.html date_hierarchy.html delete_confirmation.html object_history.html pagination.html popup_response.html prepopulated_fields_js.html search_form.html submit_line.html For those templates that cannot be overridden in …
Reference
GEOS API
This output may be in the form of a string, buffer, or even another object. GEOSGeometry.ewkt : Returns the “extended” Well-Known Text of the geometry. This representation is specific to PostGIS and is a superset of the OGC WKT standard.
Reference
Quite commonly in web applications, you need to display a one-time notification message (also known as “flash message”) to the user after processing a form or some other types of user input.
Reference
The messages framework
classviews.SuccessMessageMixin : Adds a success message attribute to FormView based classes Example views.py: The cleaned data from the form is available for string interpolation using the %(field_name)s syntax.
Reference
PostgreSQL specific model fields
Django’s model and form field implementations use base classes below, and psycopg provides a register_range() to allow use of custom range types. classRangeField(**options) : Base class for model range fields. classdjango.contrib.postgres.forms.BaseRangeField : Base class for form range fields.
Reference
The “sites” framework
… lets readers sign up to get notifications when news happens. It’s pretty basic: A reader signs up on a web form and immediately gets an email saying, “Thanks for your subscription.” It’d be inefficient and redundant to implement this sign …
Reference
… easy-to-use protection against Cross Site Request Forgeries. This type of attack occurs when a malicious website contains a link, a form button or some JavaScript that is intended to perform some action on your website, using the credentials of a …
Reference
The Forms API
In the as_p(), as_ul() and as_table() shortcuts, the fields are displayed in the order in which you define them in your form class. For example, in the ContactForm example, the fields are defined in the order subject, message, contact_email, urgent.
Reference
The Forms API
The as_p(), as_ul(), and as_table() methods are shortcuts – they’re not the only way a form object can be displayed. classBoundField[source] : Used to display HTML or access attributes for a single field of a Form instance.
Reference
Model forms
ModelFormOptions.field_classes : A dictionary that maps a model field name to a Field class, which overrides the form_class used in the model field’s Field.formfield() method.
Reference
Model forms
ModelFormOptions.localized_fields : A tuple or list of model field names to be localized. The value '__all__' can be used to specify that all fields should be localized.
Reference
Model forms
modelform_factory(model,form=ModelForm,fields=None,exclude=None,formfield_callback=None,widgets=None,localized_fields=None,labels=None,help_texts=None,error_messages=None,field_classes=None)[source] : Returns a ModelForm class for the given model. You can optionally pass a form argument to use as a starting point for constructing the ModelForm.
Reference
Widgets
… you will need to specify additional attributes at the time when the widget object is instantiated and assigned to a form field (and perhaps add some rules to your CSS files). For example, take the following form: This form will …
Reference
Middleware
classCsrfViewMiddleware[source] : Adds protection against Cross Site Request Forgeries by adding hidden form fields to POST forms and checking requests for the correct value. See the Cross Site Request Forgery protection documentation.
Reference
Model field reference
classBigIntegerField(**options)[source] A 64-bit integer, much like an IntegerField except that it is guaranteed to fit numbers from -9223372036854775808 to 9223372036854775807. The default form widget for this field is a NumberInput.
Reference
Model field reference
classBooleanField(**options)[source] A true/false field. The default form widget for this field is CheckboxInput, or NullBooleanSelect if null=True. The default value of BooleanField is None when Field.default isn’t defined.
Reference
Model field reference
Takes the same extra arguments as DateField. The default form widget for this field is a single DateTimeInput. The admin uses two separate TextInput widgets with JavaScript shortcuts. WARNING: Always use DateTimeField with a datetime.datetime > instance.
Reference
Model field reference
The default form widget for this field is a NumberInput when localize is False or TextInput otherwise. NOTE: The FloatField class is sometimes mixed up with the > DecimalField class.
Reference
Model field reference
classGenericIPAddressField(protocol='both',unpack_ipv4=False,**options)[source] An IPv4 or IPv6 address, in string format (e.g. 192.0.2.30 or 2a02:42fe::4). The default form widget for this field is a TextInput.
Reference
Model field reference
The default form widget for this field is a Textarea. If you specify a max_length attribute, it will be reflected in the Textarea widget of the auto-generated form field. However it is not enforced at the model or database level.