[Fixed]-Django: how to import static files dynamically from context variable?

1👍

You set the context variable “theme” (lowercase):

def theme(request):
    return {'theme': getattr(settings, "THEME", None)}

But you’re looking for the variable “THEME” (uppercase):

Failed lookup for key [THEME]

And as Daniel suggest (was about to do the same): write your own templatetag instead. Should take about two or three lines…

Leave a comment