I'm not using RequestContext(). The behavior must have changed between v1.4 and v1.5 regarding this.
On Tue, 2013-09-17 at 08:27 -0700, Kelvin Wong wrote: > If your software works then I guess it works, but I just ran this in > the shell on Django 1.5.4. > > > $ python manage.py shell > Python 2.7.3 (default, May 4 2012, 11:07:18) > [GCC 4.0.1 (Apple Inc. build 5493)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > (InteractiveConsole) > >>> from django.conf import settings > >>> settings.STATIC_URL > '/static/' > >>> settings.DEBUG > False > >>> from django.http import HttpRequest > >>> r = HttpRequest() > >>> from django.template import Template > >>> t = Template("{{ STATIC_URL }}") > >>> from django.template import RequestContext > >>> c = RequestContext(r, {}) > >>> t.render(c) > u'/static/' > >>> import django > >>> django.get_version() > '1.5.4' > > > If you look at django.core.context_processors you can see that the > STATIC_URL is placed in the RequestContext unconditionally on line 65: > > > https://github.com/django/django/blob/stable/1.5.x/django/core/context_processors.py > > > > K > > > > > > On Tuesday, September 17, 2013 6:09:54 AM UTC-7, Adam wrote: > Turns out that I had to use the new {% static %} template > tag. It seems > that STATIC_URL is only set in the context for template use > when in > DEBUG mode (didn't look in the code, but it appears that > way). > > {% static %} works for both development and production > environments. It > was pretty simple for me to switch. All STATIC_ variables > were already > set correctly. I just needed to add this to the top of my > base template > file: > > {% load static %} > {% get_static_prefix as STATIC_URL %} > > and everything else remained the same. > > On Tue, 2013-09-17 at 02:42 -0700, Kelvin Wong wrote: > > Check that your STATIC_URL setting in your template is > outputting the > > same string as settings.STATIC_URL. Make sure that any > included > > local_settings.py files are not wiping out those settings. > You can > > check it using the Django shell: > > > > > > $ python manage.py shell > > > > > > >>> from django.conf import settings > > >>> settings.STATIC_URL > > '/assets/static/' > > > > > > If not, check that you're using RequestContext to render > your views. > > You can do this from the Django shell as well. > > > > > > >>> from django.http import HttpRequest > > >>> r = HttpRequest() > > >>> from django.template import Template > > >>> t = Template("{{ STATIC_URL }}") > > >>> from django.template import RequestContext > > >>> c = RequestContext(r, {}) > > >>> t.render(c) > > u'/assets/static/' > > > > > > Check that you're including > 'django.core.context_processors.static' > > in your settings.TEMPLATE_CONTEXT_PROCESSORS tuple. > > > > > > >>> settings.TEMPLATE_CONTEXT_PROCESSORS > > ('django.contrib.auth.context_processors.auth', > > 'django.core.context_processors.debug', > > 'django.core.context_processors.i18n', > > 'django.core.context_processors.media', > > 'django.core.context_processors.static', > > 'django.core.context_processors.tz', > > 'django.contrib.messages.context_processors.messages') > > > > K > > > > > > > > On Monday, September 16, 2013 12:43:04 PM UTC-7, Adam > wrote: > > Maybe this is something well known. > > > > I'm using STATIC_URL in my templates. Worked > perfectly in > > Django 1.4.x. > > Upgraded to v1.5.2. Now STATIC_URL ONLY works when > the DEBUG > > setting is > > True. When set to False (For production), > STATIC_URL is an > > empty string > > in the template. > > > > Anybody have any idea why this might be happening or > what to > > look at? > > Everything that needs to be set for STATIC_URL is > set, > > otherwise it > > wouldn't have worked in v1.4.x in the first place. > > > > -- > > Adam (ad...@csh.rit.edu) > > > > > > -- > > You received this message because you are subscribed to the > Google > > Groups "Django users" group. > > To unsubscribe from this group and stop receiving emails > from it, send > > an email to django-users...@googlegroups.com. > > To post to this group, send email to > django...@googlegroups.com. > > Visit this group at > http://groups.google.com/group/django-users. > > For more options, visit > https://groups.google.com/groups/opt_out. > > -- > Adam (ad...@csh.rit.edu) > > > -- > You received this message because you are subscribed to the Google > Groups "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > For more options, visit https://groups.google.com/groups/opt_out. -- Adam (a...@csh.rit.edu) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.