views.generic.detail.SingleObjectMixin.query_pk_and_slug

query_pk_and_slug If True, causes get_object() to perform its lookup using both the primary key and the slug. Defaults to False. This attribute can help mitigate insecure direct object reference attacks. When applications allow access to individual objects by a sequential primary key, an attacker could brute-force guess all URLs; thereby obtaining a list of all objects in the application. If users with access to individual objects should be prevented from obtaining this list, setting query_p

views.generic.detail.SingleObjectMixin.slug_url_kwarg

slug_url_kwarg The name of the URLConf keyword argument that contains the slug. By default, slug_url_kwarg is 'slug'.

views.generic.detail.SingleObjectMixin.slug_field

slug_field The name of the field on the model that contains the slug. By default, slug_field is 'slug'.

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.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.pk_url_kwarg

pk_url_kwarg The name of the URLConf keyword argument that contains the primary key. By default, pk_url_kwarg is 'pk'.

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_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.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.