1👍
You shouldn’t return a response from get_context_data()
. Instead, do that in the post()
method like this:
class BoxesView(ListView):
template_name = 'polls.html'
def post(self, request, *args, **kwargs):
form = UserRegistrationForm(request.POST)
if form.is_valid():
username = form.cleaned_data['username']
password = form.cleaned_data['password']
user = User.objects.create_user(username, password=password)
return redirect('/')
else:
return self.get(request, *args, **kwargs)
def get_context_data(self):
context = super(BoxesView, self).get_context_data()
context['form'] = UserRegistrationForm()
return context
0👍
Looks like your Form expects to have confirm_password
submitted, but that’s not part of your html form.
- How to decrease number (575) of queries in a nested loop?
- Creating Django pgSQL Query With COUNT , GROUP BY , INTERVAL and LIMIT
- Do force-download responses need to be handled by angular to work? (download requested from an angular $http.post call)
- Filter by value from Db
Source:stackexchange.com