31
I think that you shouldnโt use name certifier for that foreign key relation because class Profile actually has certifier
, admin
and designer
fields(although by descriptor) according to docs and in that case names actually would clash.
from django.contrib.auth.models import User
c = Certifier.objects.create(
type='admin',
user=User.objects.latest('date_joined'),
)
p = c.profile_ptr
print(p.certifier) #username (admin)
Change to something like certifier_field = models.ForeignKey(Certifier)
As it was pointed out in comments, you could rename the models to CertifierProfile, AdminProfile etc to avoid the clash.
Or you could also silence the check by adding SILENCED_SYSTEM_CHECKS = ['models.E006']
to your settings
, but this is not a good approach.
30
You can specify Profile
is an abstract class. This will stop the check from being confused with your parent fields.
class Meta:
abstract = True
- [Django]-Annotate a sum of two fields multiplied
- [Django]-Adding a jQuery script to the Django admin interface
- [Django]-How to simplify migrations in Django 1.7?
Source:stackexchange.com