In my data model I created a UserProfile model that has a OneToOneField with User so that I could add some app specific fields for my users. Was working well enough. Then I wanted to make the email field unique…
So I created:
class CustomUser(AbstractUser):
email = models.EmailField(unique=True) # Ensure unique email addresses
and changed my OneToOneField to map to CustomUser rather than User.
(a) Is this a good way to add a few fields for my user records?
(b) When I tried the above I got stuck in ForeignKey exception hell… I cannot delete existing User or UserProfile records without throwing exceptions. I’m at an early stage here and am happy to just nix any User and UserProfile records to straighten this out. But I don’t know how to do that.
Advice and suggestions welcome. Thanks!