gis.gdal.OGRGeometry.close_rings()

close_rings() If there are any rings within this geometry that have not been closed, this routine will do so by adding the starting point to the end: >>> triangle = OGRGeometry('LINEARRING (0 0,0 1,1 0)') >>> triangle.close_rings() >>> triangle.wkt 'LINEARRING (0 0,0 1,1 0,0 0)'

admin.ModelAdmin.get_changelist_form()

ModelAdmin.get_changelist_form(request, **kwargs) [source] Returns a ModelForm class for use in the Formset on the changelist page. To use a custom form, for example: from django import forms class MyForm(forms.ModelForm): pass class MyModelAdmin(admin.ModelAdmin): def get_changelist_form(self, request, **kwargs): return MyForm Note If you define the Meta.model attribute on a ModelForm, you must also define the Meta.fields attribute (or the Meta.exclude attribute). Howeve

db.models.Prefetch

class Prefetch(lookup, queryset=None, to_attr=None) [source] The Prefetch() object can be used to control the operation of prefetch_related(). The lookup argument describes the relations to follow and works the same as the string based lookups passed to prefetch_related(). For example: >>> Question.objects.prefetch_related(Prefetch('choice_set')).get().choice_set.all() <QuerySet [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]> # This wil

postgres.forms.SimpleArrayField.base_field

base_field This is a required argument. It specifies the underlying form field for the array. This is not used to render any HTML, but it is used to process the submitted data and validate it. For example: >>> from django.contrib.postgres.forms import SimpleArrayField >>> from django import forms >>> class NumberListForm(forms.Form): ... numbers = SimpleArrayField(forms.IntegerField()) >>> form = NumberListForm({'numbers': '1,2,3'}) >>> form

views.decorators.csrf.requires_csrf_token()

requires_csrf_token(view) Normally the csrf_token template tag will not work if CsrfViewMiddleware.process_view or an equivalent like csrf_protect has not run. The view decorator requires_csrf_token can be used to ensure the template tag does work. This decorator works similarly to csrf_protect, but never rejects an incoming request. Example: from django.views.decorators.csrf import requires_csrf_token from django.shortcuts import render @requires_csrf_token def my_view(request): c = {}

admin.InlineModelAdmin.max_num

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. See Limiting the number of editable objects for more information. InlineModelAdmin.get_max_num() also allows you to customize the maximum number of extra forms.

auth.models.User.username

username Required. 150 characters or fewer. Usernames may contain alphanumeric, _, @, +, . and - characters. The max_length should be sufficient for many use cases. If you need a longer length, please use a custom user model. If you use MySQL with the utf8mb4 encoding (recommended for proper Unicode support), specify at most max_length=191 because MySQL can only create unique indexes with 191 characters in that case by default. Usernames and Unicode Django originally accepted only ASCII let

views.generic.list.MultipleObjectTemplateResponseMixin.get_template_names()

get_template_names() Returns a list of candidate template names. Returns the following list: the value of template_name on the view (if provided) <app_label>/<model_name><template_name_suffix>.html

admin.ModelAdmin.has_module_permission()

ModelAdmin.has_module_permission(request) Should return True if displaying the module on the admin index page and accessing the module’s index page is permitted, False otherwise. Uses User.has_module_perms() by default. Overriding it does not restrict access to the add, change or delete views, has_add_permission(), has_change_permission(), and has_delete_permission() should be used for that.

shortcuts.get_object_or_404()

get_object_or_404(klass, *args, **kwargs) [source] Calls get() on a given model manager, but it raises Http404 instead of the model’s DoesNotExist exception.