2012-02-14 49 views
0

我正在嘗試創建一個用戶配置文件對象;我的models.py目前寫着:爲什麼我嘗試使用Django用戶配置文件出錯?

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在項目中定義,/用戶/喬納森/ PIM的根源。這是否需要轉移到項目中的應用程序?目前我沒有將應用程序切掉。

--SECOND EDIT--

一個壓縮包是在http://JonathansCorner.com/project/pim.tgz

+0

如果我設置「user = models.OneToOneField(User)」,它也具有相同的行爲。 – JonathanHayward 2012-02-14 18:18:40

回答

2

我認爲你需要

AUTH_PROFILE_MODULE = 'app.UserProfile' 

(注意app.Model,不models.UserProfile

其中app是名稱您的應用程序

+0

當我將它設置爲'pim.UserProfile'時,出現相同的錯誤。 – JonathanHayward 2012-02-14 18:13:40

+0

@JonathanHayward:您網站/應用程序樹中的軟件包名稱究竟是什麼**?請**更新**問題。 – 2012-02-14 18:27:09

0

從外觀上看,pim從INSTALLED_APPS設置中丟失

相關問題