2👍
if request.method == 'POST':
form = registrationform(request.POST)
if form.is_valid():
data =form.save()
#...
id = data.id
#...
return HttpResponseRedirect(reverse('reg.views.thanks', args=(id)))
0👍
user = form.save(commit=False)
user.first_name = u'First name'
user.last_name = u'Last name'
user.save()
For password use password1 field
👤ssbb
- [Answered ]-Custom Django Authentication
- [Answered ]-How to autofill fields in django
- [Answered ]-URL not resolved with APIView in Django REST Framework for non-model end point
- [Answered ]-How to allow for complex URLs on a Django-rest-framework viewset
- [Answered ]-My virtualenv is not taking into account ? [apache, mod_wsgi and django]
0👍
How about changing your registration function to this:
def registration(request):
if request.method == 'POST':
form = registrationform(request.POST)
if form.is_valid():
userdetails = form.save()
user = userdetails.username
val = registration.objects.get(username = user)
return HttpResponseRedirect(reverse('reg.views.thanks', args=(val.id)))
else:
form = registrationform()
return render_to_response('registration.html', {'form' : form}, context_instance=RequestContext(request))
I suggest you read this: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
- [Answered ]-Celery/django duplicate key violations
- [Answered ]-Not able to add html tags through jQuery in django
- [Answered ]-Django Manager not updating result
- [Answered ]-Why can't apache see my python module?
- [Answered ]-Django authentication from iOS client
0👍
Please could you paste your urls.py
?
I recently had a problem almost exactly the same as this – it was just a typo there, I had the wrong value in in second field of the url function:
url(r'^people/thanks/(?P<person_id>\d+)$', 'people.views.thanks'),
Should have been:
url(r'^people/thanks/(?P<person_id>\d+)$', 'people.views.new'),
- [Answered ]-Parent calling abstract method in python
- [Answered ]-Nested Serializers Django Rest Framework
- [Answered ]-Django: Transferring/Accessing forms full error message
Source:stackexchange.com