我从userna收到以下错误:SiteProfileNotAvailable我知道错误意味着什么,但AUTH_PROFILE_MODULE中的路径是正确的,所以为什么我收到此错误?
由于
settings.py
# My apps
INSTALLED_APPS += (
'project.apps.ranger',
)
#userna
ANONYMOUS_USER_ID = -1
AUTH_PROFILE_MODULE = 'project.apps.ranger.Profile'
模型:
from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from userena.models import UserenaLanguageBaseProfile
class Profile(UserenaLanguageBaseProfile):
"""
Default profile of Ranger
"""
GENDER_CHOICES = (
(1, _('Male')),
(2, _('Female')),
)
EYE_CHOICES = (
(1, _('Blue')),
(2, _('Green')),
(3, _('Brown')),
)
gender = models.PositiveSmallIntegerField(_('gender'),
choices=GENDER_CHOICES,
blank=True,)
user = models.OneToOneField(User,
unique=True,
verbose_name=_('user'),
related_name='user_profile')
完全错误:
SiteProfileNotAvailable at /
No exception supplied
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.5.1
Exception Type: SiteProfileNotAvailable
Exception Location: /Users/user/Documents/workspace/project/django-env/lib/python2.7/site-packages/userena/utils.py in get_profile_model, line 119
Python Executable: /Users/user/Documents/workspace/project/django-env/bin/python
Python Version: 2.7.2
Python Path:
['/Users/user/Documents/workspace/project',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg',
'/Users/user/Documents/workspace/project/django-env/lib/python27.zip',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7/plat-darwin',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7/plat-mac',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/user/Documents/workspace/project/django-env/Extras/lib/python',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7/lib-tk',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7/lib-old',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/user/Documents/workspace/project/django-env/lib/python2.7/site-packages']
文件结构如下:
project
/project
/apps
/settings
/logs
/requirements
答案 0 :(得分:4)
我认为您的问题可能与您如何指定AUTH_PROFILE_MODULE设置有关。尝试使用ranger.profile
代替project.apps.ranger.profile
。
请参阅此blog post。
答案 1 :(得分:0)
奇怪的是,当我有循环依赖时,这个错误似乎经常发生在我身上。例如,将模型从django应用程序导入到models.py文件中时,该文件本身会导入到第一个模型中。如果您遇到此错误,请检查您是否正在进行循环导入。