On Jul 28, 4:21 pm, Andreas Pfrengle <a.pfren...@gmail.com> wrote: > Hi, > > we've been trying for hours now to include a css-file in our project, > but it just doesn't work and we don't know why. We've already reduced > the project to the absolute minimum of necessary code: > ---------------------------- > #settings.py: > PROJECT_PATH = os.path.abspath(os.path.dirname(__file__)) > MEDIA_ROOT = os.path.normpath(os.path.join(PROJECT_PATH, > 'site_media/')) > TEMPLATE_DIRS = ('templates', ) > <Rest is merely the default settings when starting a new project; the > app is included in ISTALLED_APPS> > > #site_media/css/test.css: > body { > background: #9ba49b url("../images/test.jpg"); } > > #site_media/images/test.jpg: > <a jpg image> > > #templates/base.html: > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > <html> > <head> > <link rel="stylesheet" href="../site_media/css/test.css" type="text/ > css" media="screen" /> > </head> > <body> > test > </body> > </html> > > #testapp/views.py: > from django.shortcuts import render_to_response > from django.template import Context, RequestContext > > def home(request): > data = {} > return render_to_response('base.html', RequestContext(request, > data)) > > -------------------- > When I drag base.html in the browser, the css is included, loading the > test.jpg image. When loading the page in the django-project, the css > isn't loaded (neither the background color, nor the image). When I > include the css code directly in base.html <style> tag, the background > color is set, but still the image is not loaded (after adjusting the > relative url). > Somehow I feel there's a problem with the path Django tries to access. > However, the method we've defined the PROJECT_PATH and MEDIA_ROOT in > the settings.py already worked in another project. Something else must > be missing, but what? > > Thanks in advance for any advice, > Andreas
You haven't shown your urls.py, but do you have anything actually serving from ../site_media/? Have you set up Django to do it (via the development server), or Apache? -- DR. -- 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.