Django simple Captcha "No module named fields" error - django

Hi I am trying to implement Django simple capcha into my app but when i try to import from view.py "from captcha.fields import CaptchaField" i get an error "No module named fields". but i am able to import this in the django shell terminal. What else am i missing

Did you add captcha to the INSTALLED_APPS in your settings.py?
If so, did you install it, where did you install it, and is it on your Python path?

I encountered same problem before and I installed django-simple-captcha. It worked finally

Related

No module named middleware for django-bouncer

I'm using django-bouncer to make a waiting list in a Django 1.6 app. Unfortunately, when I add 'bouncer.middleware.MembersOnlyMiddleware' to my MIDDLEWARE_CLASSES as required, I get: "ImportError: No module named middleware." I tried going into the Django shell and typing "from bouncer.middleware import MembersOnlyMiddleware," but that received the same error.
What can I do to resolve this problem?
django-bouncer and bouncer are not the same package.
Try to install django-bouncer:
pip install django-bouncer

Django User Registration Issue

Django newbie, running on Ubuntu 12.04, Django 1.3.1 and apt-get install python-django-registration.
Trying build a demo site to use the user registration module. I followed the steps from http://lightbird.net/dbe/forum3.html. But when I try to access accounts/ or admin/, getting the following error: "name 'registration' is not defined"
I am able to access the admin interface, after commenting out the registration part in urls.py. Any tips to overcome this issue?
is "registration" in INSTALLED_APPS in settings.py?
Is django-registration on your PYTHONPATH? Also I assume that you did syncdb after adding registration to installed app. If both are true, then try opening a shell prompt with python manage.py shell and import something from the registration module and see what error that gives

Eclipse+PyDev: pydev can't find django.contrib.messages

When, from Eclipse, i run my django project, it throws
ImportError django.contrib.messages: No module named messages
Furthermore, in django consolle import django.contrib works fine, it throws
ImportError: No module named messages
Why?
In my django folder, where the python interpreter of pydev points, there is ./contrib/messages folder, so i don't understand why it can't find django.contrib.messages
I have resolved deleting old version of django that was in /usr/lib/pymodules/python2.6/
and reinstalling django.

Can't use django management commands because of Import Errors when haystack tries to import multiligualmodel

I'm using django-haystack for searching on my site.
I'm also using django multilingual model for I18n.
I import MultilingualModel in search_indexes.py
I ca run all manangement commands as long as I don't have haystack in the INSTALLED_APPS.
When haystack is in the INSTALLED_APPS and try to run syncdb or migrate (and several other management commands) I'm always getting:
django.core.exceptions.ImproperlyConfigured: ImportError haystack: cannot import name MultilingualModel
This is likely related to the hacks done in haystack.autodiscover(). This behavior is documented here: http://docs.haystacksearch.org/dev/debugging.html#import-errors-on-start-up-mentioning-handle-registrations There is a long discussion in this ticket: https://github.com/toastdriven/django-haystack/issues/84
The long and short if it is that moving haystack.autodiscover() into your urls.py can sometimes resolve this issue. Setting HAYSTACK_ENABLE_REGISTRATIONS = False when running syncdb or migrate has resolved this for me using this snippet in my settings.py:
# FIXME: This is a complete hack to get around circular imports in
# django-haystack and other apps such as django-endless-pagination
SKIP_COMMANDS = ['syncdb', 'migrate', 'schemamigration', 'datamigration']
if any([command in sys.argv for command in SKIP_COMMANDS]):
HAYSTACK_ENABLE_REGISTRATIONS = False
search_indexes.py doesn't get processed unless haystack is in INSTALLED_APPS. The problem is with the import of MultilingualModel in general. Either it's not truly installed in your environment (attempt to import it from a vanilla python shell), or you have the import wrong (it's actually in another module, for example).
Once you can successfully import MultilingualModel from a python shell, you won't have any problems.

Configuration error in django

I am using django with mod_python (I know it is deprecated -- I am just doing this for an exercise), and am getting the following error --
"Could not import project.views. Error was: No module named app.models"
I am getting the 'No module named app.models" in several other places as well. My syncdb is working fine, and if I go into the manage.py shell I can import the models fine. Why is this occurring and what do I need to change? Thank you.
You should use absolute imports everywhere. If your project is structured like so:
/project/settings.py
/project/app/models.py
/project/app/views.py
In INSTALLED_APPS you would use project.app. In app you'd import your models into views: import project.app.models, etc. Alternately you can try adjusting your PYTHONPATH so your imports work. When you run ./manage.py you are in your project folder, and Python automatically adds it to the PYTHONPATH. This doesn't happen automatically in most deployment scenarios (mod_python or other wise).