Re: Using STATIC_URL in CSS/JS files?
Appart of using relative paths when I want to use STATIC_URL in
javascript I define a global javascript variable in my base.html
template, so it is available in my javascript files.
<script>
window.STATIC_URL = '{{STATIC_URL}}';
</script>
On Jan 3, 4:38 am, Andres Reyes <armo...@gmail.com> wrote:
> If you're serving your media from the same domain as your CSS i'd use
> relative paths
>
> 2012/1/2 Christophe Pettus <x...@thebuild.com>:
>
>
>
>
>
>
>
>
>
>
>
> > On Jan 2, 2012, at 5:56 PM, Victor Hooi wrote:
> >> E.g. I have a CSS file that points to a PNG sprite, and I'd like a way to get it to point to {{ STATIC_URL}} without hardcoding the URL/path - any way?
>
> > You can use Django to serve your CSS file if you want to, although you'll want to cache the heck out of it for performance reasons. There are also a wide variety of tools which generate CSS from various input files to allow for various kind of template expansion, and those might be a suitable alternative.
>
> > --
> > -- Christophe Pettus
> > x...@thebuild.com
>
> > --
> > 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+unsubscribe@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Andrés Reyes Monge
> armo...@gmail.com
> +(505)-8873-7217
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home