db.models.query.QuerySet.reverse()

reverse() Use the reverse() method to reverse the order in which a queryset’s elements are returned. Calling reverse() a second time restores the ordering back to the normal direction. To retrieve the “last” five items in a queryset, you could do this: my_queryset.reverse()[:5] Note that this is not quite the same as slicing from the end of a sequence in Python. The above example will return the last item first, then the penultimate item and so on. If we had a Python sequence and looked at

views.generic.dates.DayMixin

class DayMixin [source] A mixin that can be used to retrieve and provide parsing information for a day component of a date. Methods and Attributes day_format The strftime() format to use when parsing the day. By default, this is '%d'. day Optional The value for the day, as a string. By default, set to None, which means the day will be determined using other means. get_day_format() [source] Returns the strftime() format to use when parsing the day. Returns day_format by default

db.backends.base.schema.BaseDatabaseSchemaEditor.remove_field()

BaseDatabaseSchemaEditor.remove_field(model, field) [source] Removes the column(s) representing the field from the model’s table, along with any unique constraints, foreign key constraints, or indexes caused by that field. If the field is a ManyToManyField without a value for through, it will remove the table created to track the relationship. If through is provided, it is a no-op.

utils.feedgenerator.get_tag_uri()

get_tag_uri(url, date) [source] Creates a TagURI. See https://web.archive.org/web/20110514113830/http://diveintomark.org/archives/2004/05/28/howto-atom-id

template.response.SimpleTemplateResponse.__init__()

SimpleTemplateResponse.__init__(template, context=None, content_type=None, status=None, charset=None, using=None) [source] Instantiates a SimpleTemplateResponse object with the given template, context, content type, HTTP status, and charset. template A backend-dependent template object (such as those returned by get_template()), the name of a template, or a list of template names. context A dict of values to add to the template context. By default, this is an empty dictionary. content_t

admin.ModelAdmin.prepopulated_fields

ModelAdmin.prepopulated_fields Set prepopulated_fields to a dictionary mapping field names to the fields it should prepopulate from: class ArticleAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ("title",)} When set, the given fields will use a bit of JavaScript to populate from the fields assigned. The main use for this functionality is to automatically generate the value for SlugField fields from one or more other fields. The generated value is produced by concatenating the val

db.models.query.QuerySet.datetimes()

datetimes(field_name, kind, order='ASC', tzinfo=None) Returns a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet. field_name should be the name of a DateTimeField of your model. kind should be either "year", "month", "day", "hour", "minute" or "second". Each datetime.datetime object in the result list is “truncated” to the given type. order, which defaults to 'ASC', should be either 'ASC'

conf.urls.static.static()

static.static(prefix, view=django.views.static.serve, **kwargs) Helper function to return a URL pattern for serving files in debug mode: from django.conf import settings from django.conf.urls.static import static urlpatterns = [ # ... the rest of your URLconf goes here ... ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

views.generic.dates.MonthMixin.get_month()

get_month() [source] Returns the month for which this view will display data, as a string. Tries the following sources, in order: The value of the MonthMixin.month attribute. The value of the month argument captured in the URL pattern. The value of the month GET query argument. Raises a 404 if no valid month specification can be found.

Django Exceptions

Django raises some of its own exceptions as well as standard Python exceptions. Django Core Exceptions Django core exception classes are defined in django.core.exceptions. AppRegistryNotReady exception AppRegistryNotReady [source] This exception is raised when attempting to use models before the app loading process, which initializes the ORM, is complete. ObjectDoesNotExist exception ObjectDoesNotExist [source] The base class for DoesNotExist exceptions; a try/except for ObjectDoesNotE