Simple question:
What happens to {{ STATIC_URL }} variable in deployment?. For example, if I’m using a filter like this:
@register.filter
def new_filter(g):
from myapp import settings
STATIC_URL = settings.STATIC_URL
return STATIC_URL + 'dir/' + g
Am I going to have problems or Django will still point to the same STATIC_URL as it is in localhost?.
I have read the documentation but I’m still not sure about this.
Regards
Your filter will always point to whatever is defined in
settings.STATIC_URL– end of story.If you change the settings for production, your filter will now point to your new
STATIC_URL. If you don’t, it wont.If your
STATIC_URLis a relative URL, your URLs will automatically resolve to the host./static/on development might be looked up as localhost/static//static/on production example.com the browser will attempt example.com/static/If it’s absolute, then well production or development the browser will read the same resource until you change
STATIC_URL.