I dont understand why some fields of my models clash.
I dont have any foreign key so why would they clash ?!
Here is my code:
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import AbstractUser
import datetime
import uuid
# Create your models here
class Patients(AbstractUser):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
first_name = models.CharField(max_length = 255)
last_name = models.CharField(max_length = 255)
dob = models.DateField(datetime.date.today)
gender = models.CharField(max_length = 1)
def __unicode__(self):
return self.id
Here is the error:
api.Patients.groups: (fields.E304) Reverse accessor for 'Patients.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'Patients.groups' or 'User.groups'.
api.Patients.user_permissions: (fields.E304) Reverse accessor for 'Patients.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'Patients.user_permissions' or 'User.user_permissions'.
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'Patients.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'Patients.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'Patients.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'Patients.user_permissions'.
You need to add AUTH_USER_MODEL
to your setting.py
file. Django needs to know that to initialise the default model. You can add that as follows:
AUTH_USER_MODEL = 'your_app.Patients'
Check this in the documentation Substituting a custom User model
Reference: https://stackoverflow.com/a/26703434/4575071
is using AbstractUser, then you should use into file settings.py:
AUTH_USER_MODEL = 'user.user'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With