Instead of passing media_url to each view, I do the following: 1) in my urls.py I put: ... url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}, 'media'), ...
2) in my templates I put: ... <link rel="stylesheet" href="{% url media 'css/base.css' %}" type="text/css"> ... On Mar 4, 1:57 am, "mendes.rich...@gmail.com" <mendes...@gmail.com> wrote: > Hello Justin, > > It's a bit hard to see what's wrong based on this info. > The thing you should check is if you could access the css by > navigating to it in the url bar. > > You could check if the following would work. > > <style type='text/css' media='all'> > �...@import {{media_url}}style.css; > </style> > > another thing that is different from the alert.js is that you put a / > behind the style.css not sure if that could cause it > but try without. > > if this doesn't work could you post the html code with a link to a > javascript file in the same dir that works and css that doesn't. > > regards, > > Richard > > On Mar 3, 10:58 pm, justin jools <justinjo...@googlemail.com> wrote: > > > I have setup my static docs in root urls: > > > (r'^media/(?P<path>.*)$', 'django.views.static.serve', > > {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), > > > and am serving media_url in with my other data: views.py as follows. > > > media_url = settings.MEDIA_URL > > > def dblist(request): > > obj_list_menu = dbModel1.objects.all() > > obj_list_model = dbModel2.objects.all() > > return render_to_response('products/dblist.html', > > {'make_list': obj_list_menu, 'model_list': obj_list_model, > > 'media_url': media_url }) > > > so in my template I can reference images, fine. > > > <a href="{{ media_url }}{{ model.name }}"> > > <img src="{{ media_url }}{{ model.name }}" alt="{{ model.name }}" > > height="100"></a> > > > but for the life of me I can't figure out why I can't reference the > > style.css the same way. I tried this in base.html and it returns the > > correct url but doesnt execute it. > > > <link href="{{ media_url }}style.css/" rel="stylesheet" type="text/ > > css" /> (returns media/style.css) > > > I tried the same thing with a linked alert.js and this works fine: > > > <script type="text/javascript" src="{{ media_url }}alert.js"></script> > > > so why doesnt my style.css do anything: it is int the same media > > directory as alert.js... > > > would greatly appreciate any help, thanks. -- 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.