Editing mixinsLink para este cabeçalho

The following mixins are used to construct Django’s editing views:

FormMixinLink para este cabeçalho

class django.views.generic.edit.FormMixinLink para esta definição

A mixin class that provides facilities for creating and displaying forms.

Mixins

Métodos e Atributos

initialLink para esta definição

Um dicionário contendo dados iniciais para o formulário.

form_classLink para esta definição

A classe do “form” para instanciar.

success_urlLink para esta definição

A URL de redirecionamento para quando o “form” for processador com sucesso.

prefixLink para esta definição

The prefix for the generated form.

get_initial()Link para esta definição

Retrieve initial data for the form. By default, returns a copy of initial.

get_form_class()Link para esta definição

Retrieve the form class to instantiate. By default form_class.

get_form(form_class=None)Link para esta definição

Instantiate an instance of form_class using get_form_kwargs(). If form_class isn’t provided get_form_class() will be used.

get_form_kwargs()Link para esta definição

Build the keyword arguments required to instantiate the form.

The initial argument is set to get_initial(). If the request is a POST or PUT, the request data (request.POST and request.FILES) will also be provided.

get_prefix()Link para esta definição

Determine the prefix for the generated form. Returns prefix by default.

get_success_url()Link para esta definição

Determine the URL to redirect to when the form is successfully validated. Returns success_url by default.

form_valid(form)Link para esta definição

Redirects to get_success_url().

form_invalid(form)Link para esta definição

Renders a response, providing the invalid form as context.

get_context_data(**kwargs)Link para esta definição

Calls get_form() and adds the result to the context data with the name ‘form’.

ModelFormMixinLink para este cabeçalho

class django.views.generic.edit.ModelFormMixinLink para esta definição

A form mixin that works on ModelForms, rather than a standalone form.

Since this is a subclass of SingleObjectMixin, instances of this mixin have access to the model and queryset attributes, describing the type of object that the ModelForm is manipulating.

If you specify both the fields and form_class attributes, an ImproperlyConfigured exception will be raised.

Mixins

Métodos e Atributos

modelLink para esta definição

A model class. Can be explicitly provided, otherwise will be determined by examining self.object or queryset.

fieldsLink para esta definição

A list of names of fields. This is interpreted the same way as the Meta.fields attribute of ModelForm.

This is a required attribute if you are generating the form class automatically (e.g. using model). Omitting this attribute will result in an ImproperlyConfigured exception.

success_urlLink para esta definição

A URL de redirecionamento para quando o “form” for processador com sucesso.

success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/polls/{slug}/" to redirect to a URL composed out of the slug field on a model.

get_form_class()Link para esta definição

Retrieve the form class to instantiate. If form_class is provided, that class will be used. Otherwise, a ModelForm will be instantiated using the model associated with the queryset, or with the model, depending on which attribute is provided.

get_form_kwargs()Link para esta definição

Add the current instance (self.object) to the standard get_form_kwargs().

get_success_url()Link para esta definição

Determine the URL to redirect to when the form is successfully validated. Returns django.views.generic.edit.ModelFormMixin.success_url if it is provided; otherwise, attempts to use the get_absolute_url() of the object.

form_valid(form)Link para esta definição

Saves the form instance, sets the current object for the view, and redirects to get_success_url().

form_invalid(form)Link para esta definição

Renders a response, providing the invalid form as context.

ProcessFormViewLink para este cabeçalho

class django.views.generic.edit.ProcessFormViewLink para esta definição

A mixin that provides basic HTTP GET and POST workflow.

Extends

Métodos e Atributos

get(request, *args, **kwargs)Link para esta definição

Renders a response using a context created with get_context_data().

post(request, *args, **kwargs)Link para esta definição

Constructs a form, checks the form for validity, and handles it accordingly.

put(*args, **kwargs)Link para esta definição

The PUT action is also handled and just passes all parameters through to post().

DeletionMixinLink para este cabeçalho

class django.views.generic.edit.DeletionMixinLink para esta definição

Enables handling of the DELETE http action.

Métodos e Atributos

success_urlLink para esta definição

The url to redirect to when the nominated object has been successfully deleted.

success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/parent/{parent_id}/" to redirect to a URL composed out of the parent_id field on a model.

delete(request, *args, **kwargs)Link para esta definição

Retrieves the target object and calls its delete() method, then redirects to the success URL.

get_success_url()Link para esta definição

Returns the url to redirect to when the nominated object has been successfully deleted. Returns success_url by default.