as the title reads I'm NOT getting the RelatedObjectDoesNotExist error in Django 3.1(Latest Release) I'm not using signals. I create a superuser using the (python manage.py createsuperuser) command, which, as expected, does not create a profile.
models.py '''
class User(AbstractUser):
pass
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
birth_date = models.DateField(null=True, blank=True)
'''
views.py
'''
class RegisterView(View):
def get(self, request):
form = UserSignUpForm()
# print(form)
return render(request, 'users/register.html', {'form': form})
def post(self, request):
form = UserSignUpForm(request.POST)
if form.is_valid():
form.save()
username = request.POST.get('username')
Profile.objects.create(user=User.objects.get(username=username))
return redirect('users:login-page')
return render(request, 'users/register.html', {'form': form})
'''
when I use the createsuperuser command no profile is created, so I expect to get RelatedObjectDoesNotExist if I try to sign in. But I do NOT! why is that? also if I edit the database manually and remove a profile and keep the user, the user still works with no RelatedObjectDoesNotExist error! is this something that has changed with Django 3.1 !
thank you