different template pointing

5 views
Skip to first unread message

Jlcarroll

unread,
Feb 7, 2009, 6:26:23 PM2/7/09
to smug-users
So I defined my own template and css files for my main web page, and
then enabled the admin.

When I go to the admin page, it no longer displayed correctly. How do
I get the old css/template to work on the admin pages while the new
template works on my pages?

Jlcarroll

unread,
Feb 7, 2009, 6:35:14 PM2/7/09
to smug-users
more info:

The admin tries to load

http://smug.jlcarroll.net/media/css/dashboard.css which gets a 404
error

When I create a new empty django app (without using smug at all) and
then run the development server

http://localhost:8000/media/css/dashboard.css

loads fine.

I am not sure what I did to remove the css files from media/css/ when
I created my own template, so I assume that it was something that smug
did that caused them to go away.

James

Andrew McNabb

unread,
Feb 7, 2009, 11:02:47 PM2/7/09
to smug-...@googlegroups.com
The media directory is part of Django. You'll have to have Apache serve
it up separately. See the Django docs for details.
--
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868

James Carroll

unread,
Feb 7, 2009, 11:58:53 PM2/7/09
to smug-...@googlegroups.com
will continue looking, but when I run the django development server on
cygwin, everything works fine, when I run the same identical project
and repo but with apache and mysql as the only differences, no go. So
that could be possible, I will continue looking and let you know what
I find. That seems strange though, since django is already serving the
root, it should already have control over the root/media directory and
know to serve its stuff.... that is what it does with the development
server.

James
--
"And very early in the morning
the first day of the week,
they came unto the sepulchre
at the rising of the sun..." (Mark 16:2)

Web: http://james.jlcarroll.net

Andrew McNabb

unread,
Feb 8, 2009, 12:13:35 AM2/8/09
to smug-...@googlegroups.com
On Sat, Feb 07, 2009 at 09:58:53PM -0700, James Carroll wrote:
>
> will continue looking, but when I run the django development server on
> cygwin, everything works fine, when I run the same identical project
> and repo but with apache and mysql as the only differences, no go. So
> that could be possible, I will continue looking and let you know what
> I find. That seems strange though, since django is already serving the
> root, it should already have control over the root/media directory and
> know to serve its stuff.... that is what it does with the development
> server.
>

Yeah. The Django development server automatically serves up the media
directory, but Apache has to be configured for it. That's probably what
the problem is. If you wanted Django to serve up the media stuff within
Apache, it would have to be added to urls.py.

James Carroll

unread,
Feb 8, 2009, 12:13:50 AM2/8/09
to smug-...@googlegroups.com
here is the relevant information to solve my problem, including why
the development server worked and apache didn't:

Serving media files¶

Django doesn't serve media files itself; it leaves that job to
whichever Web server you choose.

We recommend using a separate Web server -- i.e., one that's not also
running Django -- for serving media. Here are some good choices:

* lighttpd
* TUX
* A stripped-down version of Apache

If, however, you have no option but to serve media files on the same
Apache VirtualHost as Django, here's how you can turn off mod_python
for a particular part of the site:

<Location "/media">
SetHandler None
</Location>

Just change Location to the root URL of your media files. You can also
use <LocationMatch> to match a regular expression.

This example sets up Django at the site root but explicitly disables
Django for the media subdirectory and any URL that ends with .jpg,
.gif or .png:

<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
</Location>

<Location "/media">
SetHandler None
</Location>

<LocationMatch "\.(jpg|gif|png)$">
SetHandler None
</LocationMatch>

Serving the admin files¶

Note that the Django development server automagically serves admin
media files, but this is not the case when you use any other server
arrangement. You're responsible for setting up Apache, or whichever
media server you're using, to serve the admin files.

The admin files live in (django/contrib/admin/media) of the Django distribution.

Here are two recommended approaches:

1. Create a symbolic link to the admin media files from within your
document root. This way, all of your Django-related files -- code and
templates -- stay in one place, and you'll still be able to svn update
your code to get the latest admin templates, if they change.
2. Or, copy the admin media files so that they live within your
Apache document root.

James Carroll

unread,
Feb 8, 2009, 12:14:32 AM2/8/09
to smug-...@googlegroups.com
or

2. Or, copy the admin media files so that they live within your
Apache document root.

James

James Carroll

unread,
Feb 8, 2009, 12:22:34 AM2/8/09
to smug-...@googlegroups.com
haha,

success...

James

Andrew McNabb

unread,
Feb 8, 2009, 2:36:55 PM2/8/09
to smug-...@googlegroups.com
On Sat, Feb 07, 2009 at 10:22:34PM -0700, James Carroll wrote:
>
> haha,
>
> success...

Great. I'm glad that worked.

Reply all
Reply to author
Forward
0 new messages