Django admin not working with mod_python

7 views
Skip to first unread message

Shamail Tayyab

unread,
Aug 24, 2010, 2:57:12 PM8/24/10
to Django users
Hi,

I am facing an issue where I cannot get the admin interface working
properly when running mod_python. Although when running it using
development server, its works fine.

Problem:
Admin interface is missing the static contents, like css, the
interface comes though.

Related info:
OS: Ubuntu 10.04.

urls.py - related info

10 urlpatterns = patterns('',
11 (r'^admin$', include(admin.site.urls)),
12 (r'^simpleadmin$', adminview ),
13 (r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': 'static'}),

virtual host configuration:
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE chatty.settings
PythonPath "['/usr/local/test', '/usr/local/test/chatty'] +
sys.path"
PythonDebug On
AuthType basic
AuthName 'Developers access'
AuthUserFile /etc/cgi-password2
Require valid-user
</Location>
<Location "/static/">
SetHandler None
</Location>
<Directory "/usr/local/test/chatty/static/">
Options Indexes MultiViews FollowSymLinks
AllowOverride all
</Directory>

Test cases:
On accessing something like http://www.host.com/media/css/base.css
it gives 404 Not Found.

Thanks and Regards

--
Shamail Tayyab
Blog: http://shamail.in/blog

Aspontus

unread,
Aug 25, 2010, 4:03:07 PM8/25/10
to Django users
Hi.
Try putting your (r'^static/(?P<path>.*)$',
'django.views.static.serve', {'document_root': 'static'}), line of
urlconf in if clause.
It works for me.
This way you avoid confusion between your server and your django
urlconf.
The full solution requires you to import settings. The code should
look something like that:

from django.conf import settings

# here the contents of your urlconf

if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/your/path/to/static'}),
)
>   On accessing something likehttp://www.host.com/media/css/base.css
Reply all
Reply to author
Forward
0 new messages