Hi Thomas, as you can see in django docs (http://
docs.djangoproject.com/en/dev/ref/settings/#setting-MEDIA_URL)

MEDIA_URL --> it's just the url where your media (static content)
resides.
  it can be a complete url (http://....) or a reference to your
current domain (/media/)
  So in the templates you can just use:

<link href="{{MEDIA_URL}}css/base.css" rel="stylesheet" />


MEDIA_ROOT --> absolute path to the directory that holds the media
  for better portability I would advise you to use _base =
os.path.dirname(__file__) instead of the complete hardcoded path

Hope it's clear now :)

On Jul 23, 2:35 pm, Thomas <thomas.robe...@googlemail.com> wrote:
> Michale many thanks for your help.
> I added your suggestions. But that did not change the django GET
> request...
>
> It still tries to load the file
>
> http://127.0.0.1:8000/css/base.css
>
> instead of
>
> http://127.0.0.1:80/media/css/base.css
>
> Maybe it helps mentioning that this is with the Development server...
> and also an apache running on the same machine.
> If I put this in the base template it also works:
>
> <link href="http://localhost:80/media/css/base.css"; rel="stylesheet" /
>
>
>
> But I would have to change that each time...
>
> On 23 Jul., 13:35, "Michael P. Soulier" <msoul...@digitaltorque.ca>
> wrote:
>
>
>
> > On 23/07/10 Thomas said:
>
> > > Hi I am trying to include a css file and I've tried this in
> > > settings.py:
>
> > > MEDIA_URL = "http://localhost:80";
> > > MEDIA_ROOT = '/media/'
>
> > > I have an apache running there and navigating tohttp://localhost/media
> > > works fine.
> > > In my base template I have this:
>
> > > <link href="css/base.css" rel="stylesheet" />
>
> > > But it's not working as I hoped. So how can I make the request
>
> > >http://127.0.0.1:80/media/css/base.css
>
> > > instead of this:
>
> > >http://127.0.0.1:8000/css/base.css
>
> > > Did I misunderstand MEDIA_URL and/or MEDIA_ROOT ?
>
> > Your media config needs to correspond to apache config.
>
> > For example:
>
> > <Location "/media">
> > SetHandler default
> > </Location>
> > Alias /media/admin /usr/lib/python2.6/django/contrib/admin/media
> > Alias /media /path/to/my/project/media
>
> > Mike
> > --
> > Michael P. Soulier <msoul...@digitaltorque.ca>
> > "Any intelligent fool can make things bigger and more complex... It takes a
> > touch of genius - and a lot of courage to move in the opposite direction."
> > --Albert Einstein
>
> >  signature.asc
> > < 1 KBAnzeigenHerunterladen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to