views.generic.base.TemplateResponseMixin.content_type

content_type The content type to use for the response. content_type is passed as a keyword argument to response_class. Default is None – meaning that Django uses DEFAULT_CONTENT_TYPE. Methods

views.generic.base.TemplateResponseMixin

class django.views.generic.base.TemplateResponseMixin Provides a mechanism to construct a TemplateResponse, given suitable context. The template to use is configurable and can be further customized by subclasses. Attributes template_name The full name of a template to use as defined by a string. Not defining a template_name will raise a django.core.exceptions.ImproperlyConfigured exception. template_engine The NAME of a template engine to use for loading the template. template_engin

views.generic.base.RedirectView.url

url The URL to redirect to, as a string. Or None to raise a 410 (Gone) HTTP error.

views.generic.base.RedirectView.query_string

query_string Whether to pass along the GET query string to the new location. If True, then the query string is appended to the URL. If False, then the query string is discarded. By default, query_string is False. Methods

views.generic.base.RedirectView.permanent

permanent Whether the redirect should be permanent. The only difference here is the HTTP status code returned. If True, then the redirect will use status code 301. If False, then the redirect will use status code 302. By default, permanent is False. Changed in Django 1.9: The default value of the permanent attribute changed from True to False.

views.generic.base.RedirectView.pattern_name

pattern_name The name of the URL pattern to redirect to. Reversing will be done using the same args and kwargs as are passed in for this view.

views.generic.base.RedirectView.get_redirect_url()

get_redirect_url(*args, **kwargs) Constructs the target URL for redirection. The default implementation uses url as a starting string and performs expansion of % named parameters in that string using the named groups captured in the URL. If url is not set, get_redirect_url() tries to reverse the pattern_name using what was captured in the URL (both named and unnamed groups are used). If requested by query_string, it will also append the query string to the generated URL. Subclasses may imple

views.generic.base.RedirectView

class django.views.generic.base.RedirectView Redirects to a given URL. The given URL may contain dictionary-style string formatting, which will be interpolated against the parameters captured in the URL. Because keyword interpolation is always done (even if no arguments are passed in), any "%" characters in the URL must be written as "%%" so that Python will convert them to a single percent sign on output. If the given URL is None, Django will return an HttpResponseGone (410). Ancestors (MRO

views.generic.base.ContextMixin.get_context_data()

get_context_data(**kwargs) Returns a dictionary representing the template context. The keyword arguments provided will make up the returned context. Example usage: def get_context_data(self, **kwargs): context = super(RandomNumberView, self).get_context_data(**kwargs) context['number'] = random.randrange(1, 100) return context The template context of all class-based generic views include a view variable that points to the View instance. Use alters_data where appropriate Note th

views.generic.base.ContextMixin

class django.views.generic.base.ContextMixin Methods get_context_data(**kwargs) Returns a dictionary representing the template context. The keyword arguments provided will make up the returned context. Example usage: def get_context_data(self, **kwargs): context = super(RandomNumberView, self).get_context_data(**kwargs) context['number'] = random.randrange(1, 100) return context The template context of all class-based generic views include a view variable that points to the V