Python django.views.generic 模块,FormView() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用django.views.generic.FormView()

项目:csv_generator    作者:fatboystring    | 项目源码 | 文件源码
def test_extends_form_view(self):
        """
        The view should extend django FormView
        """
        self.assertTrue(issubclass(CsvExportView, FormView))
项目:WPS-3rd    作者:Fastcampus-WPS    | 项目源码 | 文件源码
def form_valid(self, form):
        username = form.cleaned_data['username']
        password = form.cleaned_data['password']

        user = authenticate(username=username, password=password)
        if user is not None:
            login(self.request, user)
        else:
            return HttpResponse('ID or PW incorrect')
        return super().form_valid(form)


# class LoginFormView(FormView):
#     template_name = 'member/login.html'
#     form_class = LoginForm
#     success_url = reverse_lazy('photo:photo_list')
#
#     def form_valid(self, form):
#         username = form.cleaned_data['username']
#         password = form.cleaned_data['password']
#
#         user = authenticate(username=username, password=password)
#         if user is not None:
#             login(self.request, user)
#         else:
#             return HttpResponse('ID or PW incorrect')
#         return super().form_valid(form)
项目:WPS-3rd    作者:Fastcampus-WPS    | 项目源码 | 文件源码
def form_valid(self, form):
        username = form.cleaned_data['username']
        password = form.cleaned_data['password']

        user = authenticate(username=username, password=password)
        if user is not None:
            login(self.request, user)
        else:
            return HttpResponse('ID or PW incorrect')
        return super().form_valid(form)


# class LoginFormView(FormView):
#     template_name = 'member/login.html'
#     form_class = LoginForm
#     success_url = reverse_lazy('photo:photo_list')
#
#     def form_valid(self, form):
#         username = form.cleaned_data['username']
#         password = form.cleaned_data['password']
#
#         user = authenticate(username=username, password=password)
#         if user is not None:
#             login(self.request, user)
#         else:
#             return HttpResponse('ID or PW incorrect')
#         return super().form_valid(form)
项目:WPS-3rd    作者:Fastcampus-WPS    | 项目源码 | 文件源码
def form_valid(self, form):
        username = form.cleaned_data['username']
        password = form.cleaned_data['password']

        user = authenticate(username=username, password=password)
        if user is not None:
            login(self.request, user)
        else:
            return HttpResponse('ID or PW incorrect')
        return super().form_valid(form)


# class LoginFormView(FormView):
#     template_name = 'member/login.html'
#     form_class = LoginForm
#     success_url = reverse_lazy('photo:photo_list')
#
#     def form_valid(self, form):
#         username = form.cleaned_data['username']
#         password = form.cleaned_data['password']
#
#         user = authenticate(username=username, password=password)
#         if user is not None:
#             login(self.request, user)
#         else:
#             return HttpResponse('ID or PW incorrect')
#         return super().form_valid(form)
项目:django-arctic    作者:sanoma    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        context = super(FormView, self).get_context_data(**kwargs)
        context['layout'] = self.get_layout()
        return context