Authenticating against django auth db from apache

110 views
Skip to first unread message

Héctor Urbina

unread,
Aug 14, 2014, 5:12:09 PM8/14/14
to django...@googlegroups.com
Hello,

I'm following intructions in https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/apache-auth/, but the wsgi.py script is giving the following error:

ImportError: Could not import settings 'uddo.settings' (Is it on sys.path? Is there an import error in the settings file?): cannot import name 'auth'


This error raises because of the line importing the check_password function. Here is my wsgi.py:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "uddo.settings")

from django.contrib.auth.handlers.modwsgi import check_password

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()



The script was working fine before adding the fourth code line (import check_password).

Anyone knows what could be happening?

Thanks,
H.

Collin Anderson

unread,
Aug 14, 2014, 5:22:27 PM8/14/14
to django...@googlegroups.com
Does commenting out the check_password line in wsgi.py actually fix the problem? Are you importing "auth" somewhere in your settings?

Héctor Urbina

unread,
Aug 19, 2014, 3:49:07 PM8/19/14
to django...@googlegroups.com
Hello Collin,

Yes, commenting out the check_password line fixes the problem. On settings, I'm importing User from django.contrib.auth.models. I discovered that commenting out that stops the ImportError. However, the authentication doesn't happen when I visit my secret location. Apache simply shows its content. I followed the cited guide closely, here is the relevant part of my apache configuration:

###
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule wsgi_module modules/mod_wsgi.so

<Directory "/srv/http">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Alias /dav /srv/http/dav
<Location "/dav">
  AuthType Basic
  AuthName "Top Secret"
  Require valid-user
  AuthBasicProvider wsgi
  WSGIAuthUserScript /path/to/django/project/wsgi.py
</Location>

I understand that, when hitting http://localhost/dav/, my django's project credentials should be asked by the page. What can be happeing?

Thanks,
H.

Héctor Urbina

unread,
Aug 19, 2014, 3:58:20 PM8/19/14
to django...@googlegroups.com
I deleted my browser's cache and it worked!. I just thought that closing my session on the django project's page would also close my session on this directory...

H.
Reply all
Reply to author
Forward
0 new messages