Simple mixinsLink para este cabeçalho
ContextMixinLink para este cabeçalho
- class django.views.generic.base.ContextMixinLink para esta definição
Atributos
- extra_contextLink para esta definição
A dictionary to include in the context. This is a convenient way of specifying some context in
as_view(). Example usage:from django.views.generic import TemplateView TemplateView.as_view(extra_context={'title': 'Custom Title'})
Métodos
- get_context_data(**kwargs)Link para esta definição
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().get_context_data(**kwargs) context['number'] = random.randrange(1, 100) return contextThe template context of all class-based generic views include a
viewvariable that points to theViewinstance.
TemplateResponseMixinLink para este cabeçalho
- class django.views.generic.base.TemplateResponseMixinLink para esta definição
Provides a mechanism to construct a
TemplateResponse, given suitable context. The template to use is configurable and can be further customized by subclasses.Atributos
- template_nameLink para esta definição
The full name of a template to use as defined by a string. Not defining a
template_namewill raise adjango.core.exceptions.ImproperlyConfiguredexception.
- template_engineLink para esta definição
The
NAMEof a template engine to use for loading the template.template_engineis passed as theusingkeyword argument toresponse_class. Default isNone, which tells Django to search for the template in all configured engines.
- response_classLink para esta definição
The response class to be returned by
render_to_responsemethod. Default isTemplateResponse. The template and context ofTemplateResponseinstances can be altered later (e.g. in template response middleware).If you need custom template loading or custom context object instantiation, create a
TemplateResponsesubclass and assign it toresponse_class.
- content_typeLink para esta definição
The content type to use for the response.
content_typeis passed as a keyword argument toresponse_class. Default isNone– meaning that Django uses'text/html'.
Métodos
- render_to_response(context, **response_kwargs)Link para esta definição
Returns a
self.response_classinstance.If any keyword arguments are provided, they will be passed to the constructor of the response class.
Calls
get_template_names()to obtain the list of template names that will be searched looking for an existent template.
- get_template_names()Link para esta definição
Returns a list of template names to search for when rendering the template. The first template that is found will be used.
The default implementation will return a list containing
template_name(if it is specified).