if userForm.is_valid():
if not user_id:
user = User.objects.create_user(
username = request.POST['username'],
email = request.POST['email'],
password = request.POST['password']
)
else:
user.username = request.POST['username']
user.email = request.POST['email']
#user.profile.picture = request.FILES['picture']
user.first_name = request.POST['first_name']
user.last_name = request.POST['last_name']
user.save()
if user_id:
profileForm = ProfileForm(request.POST, request.FILES)
if profileForm.is_valid():
print("profileForm is valid!")
profile = profileForm.save(commit=False)
if request.user.is_superuser:
profile.user = user
else:
profile.user = request.user
profile.save()