2012-05-10 21 views
0

を追加しようとしているエラー:ジャンゴ:私はここの手順に従うことをしようとしています新しいアプリ

http://dev.svetlyak.ru/optional-email-in-django-comments-en/

は、Djangoのコメントアプリで「メールアドレス」フィールドをオプションにします。具体的には、私は、次の内容の「mycomments.py」と呼ばれるファイルを作成:

from django import forms 
from django.contrib.comments.forms import CommentDetailsForm 
from django.utils.translation import ungettext, ugettext_lazy as _ 

class CommentForm(CommentDetailsForm): 
    email = forms.EmailField(label=_("Email address"), required=False) 

def get_form(): 
    return CommentForm 

をそして、私のDjangoプロジェクト(manage.pyとsettings.pyを含む同じフォルダー)のルートフォルダにそれを置きました。

INSTALLED_APPS = (
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.sites', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'django.contrib.admin', 
    'django.contrib.comments', 
    'blogs', 
    'mycomments', 
) 

COMMENTS_APP = 'mycomments' 

しかし、私は 'のpython manage.pyのrunserver' を行うときに、私は次のエラーを取得:次のように続いて、私はsettings.pyファイルに 'mycomments' を追加

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x8bb208c>> 
Traceback (most recent call last): 

File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in inner_run 
self.validate(display_num_errors=True) 

File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 249, in validate 
num_errors = get_validation_errors(s, app) 

File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 35, in get_validation_errors 
for (app_name, error) in get_app_errors().items(): 

File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 146, in get_app_errors 
self._populate() 

File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 61, in _populate 
self.load_app(app_name, True) 

File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 83, in load_app 
if not module_has_submodule(app_module, 'models'): 

File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 17, in module_has_submodule 
for entry in package.__path__: # No __path__, then not a package. 

AttributeError: 'module' object has no attribute '__path__' 

をとdevサーバは起動しません。私は間違ったことをしましたか?

答えて

1

Djangoアプリは、少なくとも__init__.pymodels.py個のファイルを持つディレクトリである必要があります。したがって、mycommentsディレクトリを作成し、__init__.pyにコードを入れて、空にmodels.pyを追加します。

+0

ありがとうございました!これは問題を解決しました。ですから、私がリンクしているチュートリアルの例では、作成者は "firefly"と呼ばれるディレクトリを作成し、そのディレクトリ内の "my_comments.py"というファイルにコードを入れて、__init__.pyファイルを空白のままにしましたか? – GChorn

+0

@GChornはい、そうだと思います。 – DrTyrsa

関連する問題