コード例 #1
0
    def post(self, request, *args, **kwargs):
        form_class = self.get_form_class()
        form = self.get_form(form_class)

        contact = Contact()
        if form.is_valid():
            contact.email = form.cleaned_data['email']
            contact.first_name = form.cleaned_data['first_name']
            contact.last_name = form.cleaned_data['last_name']
            contact.profil_picture = form.cleaned_data['profil_picture']
            contact.added_by = self.request.user
            contact.save()
            return HttpResponseRedirect('/contact/')
        else:
            return render(request, self.template_name, {'form': form})