5👍
✅
From errors you posted it looks like in fact UserProfile is not a model class, but some function (likely decorated). Review your codebase and make sure you don’t define function named UserProfile. Perhaps you have view function named UserProfile somewhere below in views.py ?
0👍
if form.is_valid():
first_name = form.cleaned_data['first_name']
last_name = form.cleaned_data['last_name']
username = form.cleaned_data['username']
email = form.cleaned_data['email']
password = form.cleaned_data['password']
reg = User.objects.create_user(
username=username,
password=password,
email=email
)
reg.is_active = True
reg.first_name = first_name
reg.last_name = last_name
new_user = reg.save()
// This will give the system seconds (time) to generate new id
// before giving to userprofile
messages.info(request, "User successfully registered. Creating profile...")
UserProfile.objects.create(user_id=new_user.id, other_field='')
............
- [Django]-Python django create own command and add list as parameter
- [Django]-Django assert that response contains one of a list of possible strings
- [Django]-Show children nodes depending on selected parent
- [Django]-Django AttributeError: 'User' object has no attribute 'set_password' but user is not override
Source:stackexchange.com