[Answered ]-Django Boolean Field used in view.py

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.

Leave a comment