Use Django subdomains to switch out the base template -
i add "dev" subdomain django site publicly testing experimental layouts. of these experiments operate on base.html
template. (for example, might try new css file coupled more fluid containers.) @ moment, alternate template lives in base_alt.html
file.
i have middleware set request
object has correct subdomain
property, , i'm using django.core.context_processors.request
context processor pass property template itself. cannot decide on correct place put logic swap out base file. here ideas:
logic in each template inherits base.html
:
{% ifequal request.subdomain "dev" %} {% extends "base_alt.html" %} {% else %} {% extends "base.html" %} {% endifequal %}
this doesn't work, 1 thing. assume i'm doing stupid wrong. seems terrible solution -- @ least dozen page-level templates inherit base.
the other mediocre idea had put both base templates in base.html
giant "if" statement.
surely there's better way?
how different django configuration files each site, different template paths configured?
if don't want copy templates, can give dev site 2 template directories - 1 modifications, (later in path) live site's template directory. if don't have template in dev templates directory, django use live one.
you don't need duplicate entire configuration file - dev configuration file should able import mysite.config_live
(or whatever live config called) override 1 setting want change.
Comments
Post a Comment