I created a UserProfile model to link the User model.
I got an error while executing python manage.py makemigrations:
django.core.exceptions.FieldError: the local field u'id 'in the class' UserProfile' collides with a field of the same name from the base class' User '
Here is the code:
from django.contrib.auth.models import User from django.db.models.signals import post_save class UserProfile(models.Model): user = models.OneToOneField(User, related_name='user_of') description = models.TextField() def create_user_profile(sender, instance, created, **kwargs): if created: profile, created = UserProfile.objects.get_or_create(user=instance) post_save.connect(create_user_profile, sender=User)
Environment: Django 1.8.2, Python 2.7.6, PostgreSQL 9.4.2
This is mistake? How did it happen that the u'id 'from' UserProfile 'encounters a "User" error ...
I tried adding a line to the settings.py file:
AUTH_PROFILE_MODULE = 'user_profile.UserProfile'
But it did not help whether it was or not.
How to fix it? Thanks!
source share