Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

loginrequiredmixin

from django.contrib.auth.mixins import LoginRequiredMixin

class NippoCreateFormView(LoginRequiredMixin, CreateView):
    template_name = "nippo/nippo-formclass.html"
    form_class = NippoModelForm
    success_url = reverse_lazy("nippo-list")

    def get_form_kwargs(self):
        kwgs = super().get_form_kwargs()
        kwgs["user"] = self.request.user
        return kwgs
Source by docs.djangoproject.com #
 
PREVIOUS NEXT
Tagged: #loginrequiredmixin
ADD COMMENT
Topic
Name
9+8 =