forms.Form.fields

Form.fields You can access the fields of Form instance from its fields attribute: >>> for row in f.fields.values(): print(row) ... <django.forms.fields.CharField object at 0x7ffaac632510> <django.forms.fields.URLField object at 0x7ffaac632f90> <django.forms.fields.CharField object at 0x7ffaac3aa050> >>> f.fields['name'] <django.forms.fields.CharField object at 0x7ffaac6324d0> You can alter the field of Form instance to change the way it is presented

forms.Form.auto_id

Form.auto_id By default, the form rendering methods include: HTML id attributes on the form elements. The corresponding <label> tags around the labels. An HTML <label> tag designates which label text is associated with which form element. This small enhancement makes forms more usable and more accessible to assistive devices. It’s always a good idea to use <label> tags. The id attribute values are generated by prepending id_ to the form field names. This behavior is confi

gis.geos.fromfile()

fromfile(file_h) Parameters: file_h (a Python file object or a string path to the file) – input file that contains spatial data Return type: a GEOSGeometry corresponding to the spatial data in the file Example: >>> from django.contrib.gis.geos import fromfile >>> g = fromfile('/home/bob/geom.wkt')

apps.AppConfig.get_model()

AppConfig.get_model(model_name) [source] Returns the Model with the given model_name. Raises LookupError if no such model exists in this application. model_name is case-insensitive.

utils.translation.gettext()

gettext(message) [source] Translates message and returns it in a UTF-8 bytestring

forms.FloatField

class FloatField(**kwargs) [source] Default widget: NumberInput when Field.localize is False, else TextInput. Empty value: None Normalizes to: A Python float. Validates that the given value is a float. Leading and trailing whitespace is allowed, as in Python’s float() function. Error message keys: required, invalid, max_value, min_value Takes two optional arguments for validation, max_value and min_value. These control the range of values permitted in the field.

postgres.aggregates.RegrAvgY

class RegrAvgY(y, x) [source] Returns the average of the dependent variable (sum(y)/N) as a float, or None if there aren’t any matching rows.

http.HttpResponse.set_cookie()

HttpResponse.set_cookie(key, value='', max_age=None, expires=None, path='/', domain=None, secure=None, httponly=False) Sets a cookie. The parameters are the same as in the Morsel cookie object in the Python standard library. max_age should be a number of seconds, or None (default) if the cookie should last only as long as the client’s browser session. If expires is not specified, it will be calculated. expires should either be a string in the format "Wdy, DD-Mon-YY HH:MM:SS GMT" or a date

test.Response.json()

json(**kwargs) New in Django 1.9. The body of the response, parsed as JSON. Extra keyword arguments are passed to json.loads(). For example: >>> response = client.get('/foo/') >>> response.json()['name'] 'Arthur' If the Content-Type header is not "application/json", then a ValueError will be raised when trying to parse the response.

messages.get_messages()

get_messages(request) [source] In your template, use something like: {% if messages %} <ul class="messages"> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> {% endfor %} </ul> {% endif %} If you’re using the context processor, your template should be rendered with a RequestContext. Otherwise, ensure messages is available to the template context. Even if you know there is only just one message