1👍
✅
You are forgetting to create UserProfile with the respected user
from django.db.models.signals import post_save
from models import UserProfile
from django.contrib.auth.models import User
def register(request):
if request.method == 'POST':
uf = UserForm(request.POST, prefix='user')
upf = UserProfileForm(request.POST, prefix='userprofile')
if uf.is_valid() and upf.is_valid():
user = uf.save()
userprofile = upf.save(commit=False)
userprofile.user = user
userprofile.save() # Are you missing this line ??
return django.http.HttpResponseRedirect(…something…)
1👍
This has nothing to do with boolean fields. The error is telling you that your specific User does not have a related entry in the UserProfile table.
- [Answered ]-How use gettext in JS code correctly?
- [Answered ]-Django – TDD: 'HttpRequest' has no attribute 'POST'
- [Answered ]-How to use two different email addresses for emails sending?
Source:stackexchange.com