admin forms lose javascript with mod_python

17 views
Skip to first unread message

Eric St-Jean

unread,
Jun 26, 2007, 7:56:56 AM6/26/07
to django...@googlegroups.com
I have a weird problem where if i run django standalone, i see the
calendar widget by a DateField entry in the admin form, but when run
from mod_python, i lose it. (i lose the calendar date picking widget,
and the "today" shortcut)
/media *is* working - the css gets loaded properly. I'm using the same
browser in both instances. If i load firebug, it sees the javascript
files - i do think they are being served by apache along with the css (
i can look at them from the browser as well). But the widget doesn't
appear, and i have to enter the date by hand. I was using the debian
testing django (some form of 0.96), but then also tried trunk, with the
same results (i even removed the deb package to be absolutely sure it
wasn't used).
This is django trunk (as of yesterday), with apache 2.2.3-4 and
mod_python 3.2.10-4, python 2.4.4-2 on debian 4.0.

Any quick ideas???
Thanks

waylan

unread,
Jun 26, 2007, 11:34:15 AM6/26/07
to Django users
First check your browser settings. Is javascript enabled? Clear your
cache and then see if you can still load the js files directly. When
faced with situations like this I like to use the "Live HTTP Headers"
extension for Firefox to see whats really going on. Of course, you
could always avoid the browser and use wget (or curl) from the command
line to see if you can access the js files directly. If it is, in
fact, not a browser issue, report back and we'll see what we can do.

Hmm, before sending I reread your message and it occurs to me that as
is works with the dev server but not through apache/mod_python that
you may have some apache setting (cache related??) that's confusing
the browser. Although that doesn't make much sense if the css is
working. Either way, do the checks I suggest above and look closely at
the response headers from both servers.

Graham Dumpleton

unread,
Jun 26, 2007, 7:10:29 PM6/26/07
to Django users
Do what has been suggested with using something like live http
headers, but in particular pay close attention to the Content-Type
header being returned for static files served from your /media
directory. When using Apache the content types for such files will be
dictated by Apache configuration and/or associated mime type files. It
is possible that Django in standalone mode returns something a little
different if it is serving up the static files in that case.

Graham

On Jun 27, 1:34 am, waylan <way...@gmail.com> wrote:
> First check your browser settings. Is javascript enabled? Clear your
> cache and then see if you can still load the js files directly. When
> faced with situations like this I like to use the "Live HTTP Headers"
> extension for Firefox to see whats really going on. Of course, you
> could always avoid the browser and use wget (or curl) from the command
> line to see if you can access the js files directly. If it is, in
> fact, not a browser issue, report back and we'll see what we can do.
>
> Hmm, before sending I reread your message and it occurs to me that as
> is works with the dev server but not through apache/mod_pythonthat
> you may have some apache setting (cache related??) that's confusing
> the browser. Although that doesn't make much sense if the css is
> working. Either way, do the checks I suggest above and look closely at
> the response headers from both servers.
>
> On Jun 26, 7:56 am, Eric St-Jean <e...@wwd.ca> wrote:
>
> > I have a weird problem where if i run django standalone, i see the
> > calendar widget by a DateField entry in the admin form, but when run

> > frommod_python, i lose it. (i lose the calendar date picking widget,


> > and the "today" shortcut)
> > /media *is* working - the css gets loaded properly. I'm using the same
> > browser in both instances. If i load firebug, it sees the javascript
> > files - i do think they are being served by apache along with the css (
> > i can look at them from the browser as well). But the widget doesn't
> > appear, and i have to enter the date by hand. I was using the debian
> > testing django (some form of 0.96), but then also tried trunk, with the
> > same results (i even removed the deb package to be absolutely sure it
> > wasn't used).
> > This is django trunk (as of yesterday), with apache 2.2.3-4 and

> >mod_python3.2.10-4, python 2.4.4-2 on debian 4.0.
>
> > Any quick ideas???
> > Thanks

Eric St-Jean

unread,
Jun 27, 2007, 9:29:17 PM6/27/07
to django...@googlegroups.com
Graham Dumpleton a écrit :

> Do what has been suggested with using something like live http
> headers, but in particular pay close attention to the Content-Type
> header being returned for static files served from your /media
> directory. When using Apache the content types for such files will be
> dictated by Apache configuration and/or associated mime type files. It
> is possible that Django in standalone mode returns something a little
> different if it is serving up the static files in that case.

thanks for both of your replies. I used wireshark (previously known as
ethereal) to follow the HTTP stream (being a low-level type of guy, i
tend to use low-level type of tools :) ). Saw that the js files were
returning 404's, even though the css's weren't...

It turns out i made a mistake in the apache/mod_python config. Because i
serve multiple top-level urls from django, i use LocationMatch instead
of Location, like so:
<LocationMatch "/(blog|admin|comments|rss|i18n)/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonInterpreter wwd
SetEnv DJANGO_SETTINGS_MODULE wwd.settings
PythonDebug On
PythonPath "['/var/www/django','/var/www/django-projects'] + sys.path"
</LocationMatch>

well, the regex also catches, e.g., /media/js/admin/DateTimeShortcuts.js
even though media is normally served statically. It doesn't catch the
css media, though, because it's not in admin. Changing the regex to this:
<LocationMatch "^/(blog|admin|comments|rss|i18n)/">

solves the problem nicely.

PS: i use apache+mod_python simply because i have a few other apps that
are raw mod_python, so i need apache+mod_python anyways - i might a well
use it for django, too.

--
______________________________
Eric St-Jean e...@wwd.ca


Reply all
Reply to author
Forward
0 new messages