2012-02-09 75 views
0

我已經安裝了dipang 0.7版本的django註冊。Django註冊部分包含在django中,獲取名稱錯誤

然後用

urls.py

from core.forms import UserRegistrationForm 

from registration.views import register 

urlpatterns = patterns('', 

    url(r'^accounts/register/$', register, {'backend': 'registration.backends.default.DefaultBackend','form_class': RegistrationForm}, name='registration_register'), 
    (r'^accounts/', include('registration.urls')), 

) 

核心/ forms.py

from django import forms 
from registration.forms import RegistrationForm 
class UserRegistrationForm(RegistrationForm): 
    name = forms.CharField() 

我得到(更新

現在10
ImportError at /accounts/register/ 

No module named forms 

,如果有一個shell我做的:

>>> import registration.forms 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.6/dist-packages/registration/forms.py", line 9, in <module> 
    from django.contrib.auth.models import User 
    File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.py", line 7, in <module> 
    from django.db import models 
    File "/usr/local/lib/python2.6/dist-packages/django/db/__init__.py", line 14, in <module> 
    if not settings.DATABASES: 
    File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 276, in __getattr__ 
    self._setup() 
    File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 40, in _setup 
    raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE) 
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. 

我得到這個錯誤。

import registration進展順利,我用在urls.py registration.views.register沒有問題。

我能做些什麼來調試這個問題?

UPDATE:感謝@DrTyrsa我嘗試使用Python manage.py殼

和進口registration.forms的作品,但在我的文件不起作用

>>> import registration.forms 
>>> import core.forms 
Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
    File "/var/www/vhosts/opineo/core/forms.py", line 2, in <module> 
    from registration.forms import RegistrationForm 
ImportError: No module named forms 

我不明白爲什麼..註冊安裝了PIP和它在Python路徑

+1

嘗試導入'manage.py shell' – DrTyrsa 2012-02-10 08:53:32

+0

'NameError at/accounts/register /' - 這是NameError,而不是ImportError。你能粘貼整個視圖代碼嗎? – jholster 2012-02-10 13:46:40

+0

對不起,這是一個剪貼板錯字,一箇舊的錯誤:(錯誤總是ImportError – apelliciari 2012-02-10 22:39:52

回答

2

的解決方案是「IM白癡」 :)

當我檢查我注意到的一切時,我有一個名爲init .py的註冊文件夾。

這是覆蓋django註冊包括;重命名它,錯誤消失了。