Reputation: 9213
I'm trying to deploy my Django application to an Apache2 based server with mod_python. I've set the handlers right and made the configuration to make mod_python work with my project. My project implements a custom auth backend to connect my users to twitter, and my backend implementation is on:
myproject
|- backends/
directory.Everything seems to be working fine, my pages load and I can make read/write operations properly. But whenever I try to login with my Twitter account, application fires an exception telling me:
Error importing authentication backend backends.twitteroauth: "No module named backends.twitteroauth"
In my settings.py, I'm registering my backend as
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'myproject.backends.twitteroauth.TwitterBackend',
)
What is the problem?
Upvotes: 2
Views: 1674
Reputation: 816262
The problem is that python cannot find the module twitteroauth
. What is the name of the file TwitterBackend
is in? Also make sure that there is a __init__.py
file in backends
to mark it as a package.
edit:
What happens if you run the shell
python manage.py shell
and try to import it there?
from myproject.backends.twitteroauth import TwitterBackend
As anything else works fine, I guess myproject
is in your python path.
Upvotes: 2
Reputation: 9213
Removing database solved my problem. As far as I can guess, if a user is logged, his corresponding login backend is kept as a session variable on the database. My settings.py file was
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'backends.twitteroauth.TwitterBackend',
)
before I made the correction. Changing settings.py and restarting the application was simply not enough. You have to remove session related records from db too.
Upvotes: 2
Reputation: 2932
Make sure that backends is on the python path and has a init.py file in the folder.
Upvotes: 1