Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Abstract User Error

I am working on extending the User class based on the docs with the code below:

from django.contrib.auth.models import AbstractUser  class MyUser(AbstractUser):   some_extra_data = models.CharField(max_length=100, blank=True) 

However, I'm returning the following error

Reverse accessor for 'User.groups' clashes with reverse accessor for 'MyUser.groups'. HINT: Add or change a related_name argument to the definition for 'User.groups' or 'MyUser.groups'. 

I understand resolving this type of conflict by adding a related_name to FK. How would I resolve it in this scenario?

like image 938
byrdr Avatar asked Nov 02 '14 19:11

byrdr


2 Answers

You need to set your AUTH_USER_MODEL setting to point to your MyUser model, so that Django knows not to initialise the default model. See the documentation.

like image 118
Daniel Roseman Avatar answered Sep 19 '22 17:09

Daniel Roseman


Add this line

AUTH_USER_MODEL = "app_name.MyUser" 

in the settings.py it works.

like image 26
Deepak G Avatar answered Sep 20 '22 17:09

Deepak G