Mixins

NoLoginRequiredMixin

class boilerplate.mixins.NoLoginRequiredMixin[source]

Mixin for any class view classes that required the current user if not authenticated, redirects the user to the home page or any URL with the next parameter.

Example

class Register(NoLoginRequiredMixin, FormView):
    form_class = forms.RegisterForm

CRUDMessageMixin

class boilerplate.mixins.CRUDMessageMixin[source]

Add a message on successful form submission.

get_success_message(cleaned_data=None)[source]

Default success message mixin

CreateMessageMixin

class boilerplate.mixins.CreateMessageMixin[source]

Mixin for CreateView classes that adds a success message after the action is completed successfully.

Example

class ModelSendEmail(CreateMessageMixin, CreateView):
    model = Model

UpdateMessageMixin

class boilerplate.mixins.UpdateMessageMixin[source]

Mixin for UpdateView classes that adds a success message after the action is completed successfully.

Example

class ModelSendEmail(UpdateMessageMixin, UpdateView):
    model = Model

DeleteMessageMixin

class boilerplate.mixins.DeleteMessageMixin[source]

Mixin for DeleteView classes that adds a success message after the action is completed successfully.

Example

class ModelSendEmail(DeleteMessageMixin, DeleteView):
    model = Model

ListActionsMixin

ExtraFormsAndFormsetsMixin

class boilerplate.mixins.ExtraFormsAndFormsetsMixin[source]

Mixin for CreateView or UpdateView classes that adds extra forms and formsets to any of thoose views.

Example

class UserUpdate(ExtraFormsAndFormsetsMixin, UpdateView):
    model = User
    extra_form_list = (
        ('profile', 'user', forms.ProfileForm),
        ('credit_card', 'user', forms.ProfileForm),
    )
    formset_list = (
        (form.AddressFormSet),
        (form.PhoneFormSet),
    )
form_invalid(form, extra_forms=None, formsets=None)[source]

If the form or the extra forms are invalid, re-render the context data with the data-filled form and errors.

form_valid(form, extra_forms=None, formsets=None)[source]

If the form is valid, redirect to the supplied URL.

get_context_data(**kwargs)[source]

Insert the extra forms and formsets into the context dict.

get_extra_form_kwargs(lookup_field)[source]

Returns the keyword arguments for instantiating each extra form.

get_extra_form_list()[source]

Returns a list of extra forms with the lookup_field, relation_field and form_class to use in this view.

get_extra_forms(form_list=None)[source]

Returns a list of each extra forms to be used in this view.

get_formset_kwargs()[source]

Returns the keyword arguments for instantiating each formset.

get_formset_list()[source]

Returns a list of formsets with the formset class to use in this view.

get_formsets(formset_list=None)[source]

Returns a list of formsets to be used in this view.

post(request, *args, **kwargs)[source]

Handles POST requests, instantiating a form instance with the passed POST variables and then checked for validity.