[Django] #21313: load tag before extends

31 views
Skip to first unread message

Django

unread,
Oct 23, 2013, 1:49:29 PM10/23/13
to django-...@googlegroups.com
#21313: load tag before extends
-------------------------------+--------------------
Reporter: ztorstri@… | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I'd like to be able to load a template tag before extends. I don't want to
use a context processor because I don't want every view that uses
RequestContext to get the variable. Here's the detailed situation:

I'm designing an app, and I want the "base.html" template to be a
configurable in the settings file. So a user downloads my application,
goes to the settings file, adds the setting
"BASE_TEMPLATE_NAME=somestring", and then all of my templates
automatically inherit this base template.

If I use a context processor, then every other page on their site that
uses RequestContext will get this variable as well. I tried to use a
template tag to return the base template setting, but I can't put anything
before extends.

--
Ticket URL: <https://code.djangoproject.com/ticket/21313>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 23, 2013, 1:49:56 PM10/23/13
to django-...@googlegroups.com
#21313: load tag before extends
-------------------------------+--------------------------------------

Reporter: ztorstri@… | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by ztorstri@…):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/21313#comment:1>

Django

unread,
Oct 25, 2013, 2:47:47 PM10/25/13
to django-...@googlegroups.com
#21313: load tag before extends
-------------------------------+--------------------------------------

Reporter: ztorstri@… | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by chrismedrela):

What's wrong about putting ``BASE_TEMPLATE_NAME`` into ``RequestContext``?
This variable doesn't seem to be secret so you don't need to hide it from
other templates.

Anyway, I'm -1 on emulating 'private' variables (variables visible only in
a specific template) using template tags.

--
Ticket URL: <https://code.djangoproject.com/ticket/21313#comment:2>

Django

unread,
Oct 26, 2013, 4:16:59 PM10/26/13
to django-...@googlegroups.com
#21313: load tag before extends
-------------------------------+--------------------------------------

Reporter: ztorstri@… | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by ztorstri@…):

Replying to [comment:2 chrismedrela]:


> What's wrong about putting ``BASE_TEMPLATE_NAME`` into
``RequestContext``? This variable doesn't seem to be secret so you don't
need to hide it from other templates.
>
> Anyway, I'm -1 on emulating 'private' variables (variables visible only
in a specific template) using template tags.

It's not about being private, it's about being wasteful. There's no reason
to load the variable in templates that don't relate to the app.

I ended up writing a mixin that defines get_context and I inherit it in
the views that need the base template. It was a satisfactory solution,
but I still think it's worth considering allowing template tags to be
loaded before extends.

--
Ticket URL: <https://code.djangoproject.com/ticket/21313#comment:3>

Django

unread,
Oct 30, 2013, 12:26:25 PM10/30/13
to django-...@googlegroups.com
#21313: load tag before extends
-------------------------------+--------------------------------------
Reporter: ztorstri@… | Owner: nobody
Type: New feature | Status: closed
Component: Uncategorized | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timo):

* status: new => closed
* resolution: => needsinfo


Comment:

I guess we could consider a patch, but absent that, I'm going to close
this since there are other ways to accomplish this as described above.

--
Ticket URL: <https://code.djangoproject.com/ticket/21313#comment:4>

Reply all
Reply to author
Forward
0 new messages