db.backends.base.schema.BaseDatabaseSchemaEditor

class BaseDatabaseSchemaEditor [source] Django’s migration system is split into two parts; the logic for calculating and storing what operations should be run (django.db.migrations), and the database abstraction layer that turns things like “create a model” or “delete a field” into SQL - which is the job of the SchemaEditor. It’s unlikely that you will want to interact directly with SchemaEditor as a normal developer using Django, but if you want to write your own migration system, or have m

forms.Field.get_bound_field()

Field.get_bound_field(form, field_name) [source] Takes an instance of Form and the name of the field. The return value will be used when accessing the field in a template. Most likely it will be an instance of a subclass of BoundField. If you have a GPSCoordinatesField, for example, and want to be able to access additional information about the coordinates in a template, this could be implemented as follows: class GPSCoordinatesBoundField(BoundField): @property def country(self):

core.management.BaseCommand.execute()

BaseCommand.execute(*args, **options) [source] Tries to execute this command, performing system checks if needed (as controlled by the requires_system_checks attribute). If the command raises a CommandError, it’s intercepted and printed to stderr. Calling a management command in your code execute() should not be called directly from your code to execute a command. Use call_command() instead.

auth.mixins.AccessMixin

class AccessMixin New in Django 1.9. login_url Default return value for get_login_url(). Defaults to None in which case get_login_url() falls back to settings.LOGIN_URL. permission_denied_message Default return value for get_permission_denied_message(). Defaults to an empty string. redirect_field_name Default return value for get_redirect_field_name(). Defaults to "next". raise_exception If this attribute is set to True, a PermissionDenied exception will be raised inst

views.decorators.http.require_safe()

require_safe() Decorator to require that a view only accepts the GET and HEAD methods. These methods are commonly considered “safe” because they should not have the significance of taking an action other than retrieving the requested resource. Note Web servers should automatically strip the content of responses to HEAD requests while leaving the headers unchanged, so you may handle HEAD requests exactly like GET requests in your views. Since some software, such as link checkers, rely on HEA

forms.FilePathField.allow_files

allow_files Optional. Either True or False. Default is True. Specifies whether files in the specified location should be included. Either this or allow_folders must be True.

core.files.File.file

file The underlying file object that this class wraps. Be careful with this attribute in subclasses. Some subclasses of File, including ContentFile and FieldFile, may replace this attribute with an object other than a Python file object. In these cases, this attribute may itself be a File subclass (and not necessarily the same subclass). Whenever possible, use the attributes and methods of the subclass itself rather than the those of the subclass’s file attribute.

Deployment checklist

The Internet is a hostile environment. Before deploying your Django project, you should take some time to review your settings, with security, performance, and operations in mind. Django includes many security features. Some are built-in and always enabled. Others are optional because they aren’t always appropriate, or because they’re inconvenient for development. For example, forcing HTTPS may not be suitable for all websites, and it’s impractical for local development. Performance optimizatio

forms.Form.is_multipart()

Form.is_multipart() If you’re writing reusable views or templates, you may not know ahead of time whether your form is a multipart form or not. The is_multipart() method tells you whether the form requires multipart encoding for submission: >>> f = ContactFormWithMugshot() >>> f.is_multipart() True Here’s an example of how you might use this in a template: {% if form.is_multipart %} <form enctype="multipart/form-data" method="post" action="/foo/"> {% else %}

admin.ModelAdmin.save_as_continue

ModelAdmin.save_as_continue New in Django 1.10. When save_as=True, the default redirect after saving the new object is to the change view for that object. If you set save_as_continue=False, the redirect will be to the changelist view. By default, save_as_continue is set to True.