Closed TotallyNotChase closed 4 years ago
Note: I have already ran makemigrations
many times with many changes (after deleting all the previous migrations), I cannot seem to get rid of username
no matter what I try
The username column is not created by alllauth, you can find it inside Django's abstract user:
I'm using a custom user model with allauth and I need to have the username field omitted. I've already seen the docs and a whole bunch of stackoverflow answers about using
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
but all of this still leads my database to have an username field.Now since the db still has an
username
field with the unique constraint set on and allauth will not put a username in the field with the aforementioned setting set toNone
, this causes me to faceIntegrityError
after the very first user creation. I know I can solve this by just having the aforementioned setting be set to'username'
but I'm curious, how do I just not make the username, because I'm never using it.My model:
It doesn't really do much except override the
delete
function. It also setsfirst_name
andlast_name
toNone
, which works perfectly and removes those fields from the database as expected. I've tried settinguser
toNone
but that does nothing. I've also tried settingusername
toNone
but that will raise a FieldNotFound error withACCOUNT_USER_MODEL_USERNAME_FIELD = None
My settings (the relevant bit):
My migration file:
This migration generation confuses me to no end. Why is the
username
field still there? Why is it set to be the only unique constraint even though I've clearly setACCOUNT_UNIQUE_EMAIL = True
?At first I thought, my settings were simply not being read. But I checked
django.conf.settings
andallauth.account.app_settings
for these changes and they were all updated. What's going on here?