Unless you are trying to serve your CSS inline, which it doesn't appear to be 
the case from your post, why wouldn't you serve your CSS files like any other 
static file?  Serve the static file with your web server or CDN and put the url 
in the template, no magic required.

On Jan 19, 2011, at 3:58 PM, brian.mus...@ff0000.com wrote:

> Is it me or does it blow your mind that there is not one standard way
> of importing something as common as CSS files into Django templates?
> I realize there are a plethora of options as mentioned on the official
> site here: http://docs.djangoproject.com/en/dev/howto/static-files/
> None of which actually ended up working for me and instead ended up
> using this:
> 
> urlpatterns in urls.py:
> (r'^static/(?P<path>.*)$', 'django.views.static.serve',
> {'document_root': '/Users/home/djcode/mysite/media/
> css/','show_indexes' : True}),
> 
> and then on my actual template page:
> <link rel="stylesheet" type="text/css" href="static/my.css" />
> 
> I suppose I was feeling a little misdirected by the default
> settings.py in my projects folder where CSS and other Media are
> supposed to be stored.
> ADMIN_MEDIA_PREFIX = 'media/'  That was not used at all in the
> solution I ended up using which does work.
> 
> My main complaint is this - for something so common as importing CSS
> into django templates - why not just make it painfully obvious in the
> documentation/djangobook with one golden way of doing so - why does
> everything have to be so modular, etc?  It starts to feel
> counterproductive at a certain point - like why I am not just writing
> this in python myself if there are going to be so many options.  I
> think django could use a little tightening up. I understand it's loose
> coupling ways, etc - but don't use that as a shield for something
> possibly unfinished? The solution I ended up using felt like a hack
> for something so common.  My two cents.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@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.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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