Django Foreign Key to_field -
i have 2 models customuser , magazine random/unique slug fields. want create third model (article) foreign keys slug field: class customuser(abstractbaseuser): slug = randomslugfield(length=6, unique=true) ... class magazine(models.model): slug = randomslugfield(length=6, unique=true) name = models.charfield() class article(models.model): magazine = models.foreignkey(magazine, to_field='slug') author = models.foreignkey(settings.auth_user_model, to_field='slug') but when migrate database create article model, following error: django.core.exceptions.fielddoesnotexist: customuser has no field named 'slug' but customuser has field named 'slug'. , magazine model don't error. has idea going wrong? i use package slug field: https://github.com/mkrjhnsn/django-randomslugfield edit: here full customuser model: class customuser(abstractbaseuser, permissionsmixin): slug = randomslugfield(length=6, exclude_upp