I am trying to follow the steps here:
http://dev.svetlyak.ru/optional-email-in-django-comments-en/
to make the "Email Address" field in the Django comments app optional. Specifically, I created a file called 'mycomments.py' with the following contents:
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
And placed it in the root folder for my Django project (the same folder that contains manage.py and settings.py). Then, I added 'mycomments' to the settings.py file as follows:
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'
But then when I do 'python manage.py runserver', I get the following error:
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__'
And the dev server doesn't start up. Did I do something wrong?
Django app should be (at minimum) a directory with __init__.py
and models.py
files. So create mycomments
dir, put your code in __init__.py
and add empty models.py
there.