views.generic.dates.YearMixin.year_format

year_format The strftime() format to use when parsing the year. By default, this is '%Y'.

views.generic.detail.DetailView

class django.views.generic.detail.DetailView While this view is executing, self.object will contain the object that the view is operating upon. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.detail.SingleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.detail.BaseDetailView django.views.generic.detail.SingleObjectMixin django.views.generic.base.View Method Flowchart dispatch() http_met

views.generic.detail.SingleObjectMixin

class django.views.generic.detail.SingleObjectMixin Provides a mechanism for looking up an object associated with the current HTTP request. Methods and Attributes model The model that this view will display data for. Specifying model = Foo is effectively the same as specifying queryset = Foo.objects.all(), where objects stands for Foo’s default manager. queryset A QuerySet that represents the objects. If provided, the value of queryset supersedes the value provided for model. Warni

views.generic.detail.SingleObjectMixin.context_object_name

context_object_name Designates the name of the variable to use in the context.

views.generic.detail.SingleObjectMixin.get_context_data()

get_context_data(**kwargs) Returns context data for displaying the list of objects. The base implementation of this method requires that the self.object attribute be set by the view (even if None). Be sure to do this if you are using this mixin without one of the built-in views that does so. It returns a dictionary with these contents: object: The object that this view is displaying (self.object). context_object_name: self.object will also be stored under the name returned by get_context_o

views.generic.detail.SingleObjectMixin.get_context_object_name()

get_context_object_name(obj) Return the context variable name that will be used to contain the data that this view is manipulating. If context_object_name is not set, the context name will be constructed from the model_name of the model that the queryset is composed from. For example, the model Article would have context object named 'article'.

views.generic.detail.SingleObjectMixin.get_object()

get_object(queryset=None) Returns the single object that this view will display. If queryset is provided, that queryset will be used as the source of objects; otherwise, get_queryset() will be used. get_object() looks for a pk_url_kwarg argument in the arguments to the view; if this argument is found, this method performs a primary-key based lookup using that value. If this argument is not found, it looks for a slug_url_kwarg argument, and performs a slug lookup using the slug_field. When qu

views.generic.detail.SingleObjectMixin.get_queryset()

get_queryset() Returns the queryset that will be used to retrieve the object that this view will display. By default, get_queryset() returns the value of the queryset attribute if it is set, otherwise it constructs a QuerySet by calling the all() method on the model attribute’s default manager.

views.generic.detail.SingleObjectMixin.get_slug_field()

get_slug_field() Returns the name of a slug field to be used to look up by slug. By default this simply returns the value of slug_field.

views.generic.detail.SingleObjectMixin.model

model The model that this view will display data for. Specifying model = Foo is effectively the same as specifying queryset = Foo.objects.all(), where objects stands for Foo’s default manager.