Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Following "first app" tutorial -- admin site can't find css files [RSS Feed]

#1 Dec. 7, 2009 02:19:46

A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Following "first app" tutorial -- admin site can't find css files


I'm using svn install. I am using the same virtualhost for django and
static files, with ADMIN_MEDIA_PREFIX set to '/media/', which I
believe was the default.

The admin app works fine so far, but the server gives me a 404 on the
css files:

Using the URLconf defined in testproject.urls,
Django tried these URL patterns, in this order:
^admin/
The current URL, media/css/base.css, didn't match any of these.

Can anyone help me with this problem? I really don't understand how
the ADMIN_MEDIA_PREFIX interacts with the urlconf settings.

Thank you,
Arthur


--

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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 7, 2009 04:55:41

Waqqas J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Following "first app" tutorial -- admin site can't find css files


for test server i add the following lines in settings.py

import os
SITE_ROOT = os.path.realpath(os.path.dirname(__file__))

STATIC_DOC_ROOT = os.path.join(SITE_ROOT, 'media/')

and add the following lines in urls.py


if settings.DEBUG == True:
urlpatterns += patterns('',(r'^site_media/(?P<path>.*)$',
'django.views.static.serve',{'document_root': settings.STATIC_DOC_ROOT}),)

and put all your media files in site_media folder


for my apache + mod_python setup i ve the following lines

<Location "/">
PythonHandler django.core.handlers.modpython
PythonPath " + sys.path"
SetEnv DJANGO_SETTINGS_MODULE hospital.settings
SetHandler python-program
</Location>

<Locationmatch "^/(theme|media|site_media)/.*">
SetHandler default
</Locationmatch>

alias /media/ H:/Python25/Lib/site-packages/django/contrib/admin/media/
alias /site_media/ c:/site/hospital/media/


"SetHandler default" should be after the "SetHandler python-program" in
sequences

On Mon, Dec 7, 2009 at 7:18 AM, Arthur <adobe...@gmail.com> wrote:

> I'm using svn install. I am using the same virtualhost for django and
> static files, with ADMIN_MEDIA_PREFIX set to '/media/', which I
> believe was the default.
>
> The admin app works fine so far, but the server gives me a 404 on the
> css files:
>
> Using the URLconf defined in testproject.urls,
> Django tried these URL patterns, in this order:
> ^admin/
> The current URL, media/css/base.css, didn't match any of these.
>
> Can anyone help me with this problem? I really don't understand how
> the ADMIN_MEDIA_PREFIX interacts with the urlconf settings.
>
> Thank you,
> Arthur
>
>
> --
>
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>
>
>

--

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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 2, 2011 19:56:55

p.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Following "first app" tutorial -- admin site can't find css files


Hi Arthur,

Thanks for your post. It was one of the first I found perfectly aligned with
my current issue: showing the look & feel one would expect, while following
the official django tutorial athttp://docs.djangoproject.com/en/dev/intro/tutorial02/using django's
default *development server*.

After looking around for the replies on this post and other similar
questions on the web, I was able to fix this with these 4 actions:

1. Make sure you have the following lines in settings.py:
-
- MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media")
- MEDIA_URL = '/media/'
- ADMIN_MEDIA_PREFIX = '/media/admin/'
2. Add the following line to urls.py, as an extra parameter inside the *
patterns* function call
-
- # Required to make static serving work
- (r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
3. Build a directory structure to the above settings



<https://lh6.googleusercontent.com/_9631DYMEFh0/TSC6IKDtAAI/AAAAAAAAARQ/QK-_J47R7Ts/django.tutorial.02.directory.structure.png>
4. And, finally, copy the default admin CSS files from the django
installation onto the above structure (in my case the django CSS files were
in *C:\django\django\contrib\admin\media\css*)


Also, it helped me a lot to read these posts in the web:

-http://twigstechtips.blogspot.com/2009/08/django-how-to-serve-media-files-css.html-http://rob.cogit8.org/blog/2008/Jun/20/django-and-relativity/Have fun,
Pedro

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Following "first app" tutorial -- admin site can't find css files [RSS Feed]

Board footer

Moderator control

Enjoy the 11th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support