Writing your first Django app, part 4

This tutorial begins where Tutorial 3 left off. We’re continuing the Web-poll application and will focus on simple form processing and cutting down our code. Write a simple form Let’s update our poll detail template (“polls/detail.html”) from the last tutorial, so that the template contains an HTML <form> element: <h1>{{ question.question_text }}</h1> {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} <form action="{% url

forms.MultiValueField.compress()

compress(data_list) [source] Takes a list of valid values and returns a “compressed” version of those values – in a single value. For example, SplitDateTimeField is a subclass which combines a time field and a date field into a datetime object. This method must be implemented in the subclasses.

db.models.Field.blank

Field.blank If True, the field is allowed to be blank. Default is False. Note that this is different than null. null is purely database-related, whereas blank is validation-related. If a field has blank=True, form validation will allow entry of an empty value. If a field has blank=False, the field will be required.

forms.FileInput

class FileInput [source] File upload input: <input type='file' ...>

db.models.Options.get_latest_by

Options.get_latest_by The name of an orderable field in the model, typically a DateField, DateTimeField, or IntegerField. This specifies the default field to use in your model Manager’s latest() and earliest() methods. Example: get_latest_by = "order_date" See the latest() docs for more.

admin.models.LogEntry.action_flag

LogEntry.action_flag The type of action logged: ADDITION, CHANGE, DELETION. For example, to get a list of all additions done through the admin: from django.contrib.admin.models import LogEntry, ADDITION LogEntry.objects.filter(action_flag=ADDITION)

gis.gdal.LineString

class LineString x Returns a list of X coordinates in this line: >>> OGRGeometry('LINESTRING (1 2,3 4)').x [1.0, 3.0] y Returns a list of Y coordinates in this line: >>> OGRGeometry('LINESTRING (1 2,3 4)').y [2.0, 4.0] z Returns a list of Z coordinates in this line, or None if the line does not have Z coordinates: >>> OGRGeometry('LINESTRING (1 2 3,4 5 6)').z [3.0, 6.0]

gis.db.models.functions.GeoHash

class GeoHash(expression, precision=None, **extra) Availability: PostGIS, SpatiaLite (≥ 4.0, LWGEOM) Accepts a single geographic field or expression and returns a GeoHash representation of the geometry. The precision keyword argument controls the number of characters in the result. Changed in Django 1.10: SpatiaLite support was added.

gis.geos.GEOSGeometry.srid

GEOSGeometry.srid Property that may be used to retrieve or set the SRID associated with the geometry. For example: >>> pnt = Point(5, 23) >>> print(pnt.srid) None >>> pnt.srid = 4326 >>> pnt.srid 4326

gis.geos.GEOSGeometry.clone()

GEOSGeometry.clone() This method returns a GEOSGeometry that is a clone of the original.