为什么我尝试使用Django用户配置文件错误?

时间:2012-02-14 18:05:55

标签: python django django-models

我正在尝试制作用户个人资料对象;我的models.py目前读取:

from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.db import models

class UserProfile(models.Model):
    name = models.TextField()
    scratchpad = models.TextField()
    user = models.ForeignKey(User, unique = True)

def create_user_profile(sender, instance, created, **kwargs):
    if created:
        UserProfile.objects.create(user = instance)

 post_save.connect(create_user_profile, sender = User)

在我的settings.py中,我位于顶部:

AUTH_PROFILE_MODULE = 'models.UserProfile'

我收到错误信息:

SiteProfileNotAvailable at /
Unable to load the profile model, check AUTH_PROFILE_MODULE in your project settings
Request Method: GET
Request URL:    http://localhost:8000/
Django Version: 1.3.1
Exception Type: SiteProfileNotAvailable
Exception Value:    
Unable to load the profile model, check AUTH_PROFILE_MODULE in your project settings
Exception Location: /usr/local/Cellar/python/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py in get_profile, line 380
Python Executable:  /usr/local/bin/python
Python Version: 2.7.0
Python Path:    
['/Users/jonathan/pim',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg',
 '/usr/local/Cellar/python/2.7/lib/python27.zip',
 '/usr/local/Cellar/python/2.7/lib/python2.7',
 '/usr/local/Cellar/python/2.7/lib/python2.7/plat-darwin',
 '/usr/local/Cellar/python/2.7/lib/python2.7/plat-mac',
 '/usr/local/Cellar/python/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/usr/local/Cellar/python/2.7/lib/python2.7/lib-tk',
 '/usr/local/Cellar/python/2.7/lib/python2.7/lib-old',
 '/usr/local/Cellar/python/2.7/lib/python2.7/lib-dynload',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/PIL',
 '/usr/local/lib/python2.7/site-packages',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Server time:    Tue, 14 Feb 2012 11:48:23 -0600

models.py文件位于/ Users / jonathan / pim。

我在这里做错了什么?如何设置东西,以便models.py中的UserProfile注册为用户配置文件?

谢谢,

- 编辑 -

关于站点和包名称,我在项目的根目录models / py中定义了UserProfile,/ Users / jonathan / pim。这是否需要移动到项目中的应用程序?目前我没有切掉申请。

- 第二次编辑 -

tarball位于http://JonathansCorner.com/project/pim.tgz

2 个答案:

答案 0 :(得分:2)

我认为你需要

AUTH_PROFILE_MODULE = 'app.UserProfile' 

(注意app.Model,而不是models.UserProfile

其中app是您应用的名称

答案 1 :(得分:0)

从外观上看,INSTALLED_APPS设置中缺少pim