cannot import name User (error retrieving User from django.contrib.auth)
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I was making an application that included user profiles, and I thought I was done with the first part so I entered an sql command and got this:
Ian-Smiths-Computer:~/Sites/matches ismith$ python manage.py sql nest matches.cafe: cannot import name User 1 error found. BEGIN; CREATE TABLE `nest_userprofile` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `website` varchar(200) NOT NULL, `about` longtext NOT NULL, `avatar` varchar(100) NOT NULL, `user_id` integer NOT NULL UNIQUE REFERENCES `auth_user` (`id`) ); COMMIT;
Here is what my nest/models.py looks like:
from django.db import models from django.contrib.auth.models import User # Create your models here. class UserProfile(models.Model): website = models.URLField() about = models.TextField() avatar = models.ImageField(upload_to='avatars') user = models.ForeignKey(User, unique=True)
I'm using it to extend the User model, but for some reason it cannot connect to it. I then tried to re-SQL another app in my project that hadn't had a problem, and it gave the same error.
I even included
AUTH_PROFILE_MODULE = 'nest.UserProfile' in my project's settings.py
I was thinking maybe I should redownload django, to reset contrib/auth/models.py, just in case it got modified somehow.