Re: [Django] #24891: Warn if referencing a template by the same name as one in an installed app with higher precedence

2015-06-05 Thread Django
#24891: Warn if referencing a template by the same name as one in an installed 
app
with higher precedence
-+--
 Reporter:  giuliettamasina  |Owner:  nobody
 Type:  New feature  |   Status:  closed
Component:  Template system  |  Version:  master
 Severity:  Normal   |   Resolution:  wontfix
 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 mjtamlyn):

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


Comment:

 There's a big warning about this in the first mention of template names in
 the tutorial, recommending the use of a subfolder -
 https://docs.djangoproject.com/en/dev/intro/tutorial03/#a-shortcut-render

 This is further explained, along with the way multiple backends are
 resolved in the API docs.

 Adding such a warning would require additional work every time a template
 is selected - and would be specific to one template engine. It would
 generate unnecessary noise in the common, documented in the tutorial
 pattern of overriding an admin template with one in your own app.

 +1 to using debug toolbar.

 I don't see an obvious opportunity for more documentation as they way it
 works is mentioned several times in the API docs and twice in the
 tutorial. Adding warnings would generate unnecessary noise. Template
 overriding is an important feature. Consequently, I am closing this
 ticket.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.4309854f00b5653be7f1ae04b78dd3ec%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24891: Warn if referencing a template by the same name as one in an installed app with higher precedence

2015-06-01 Thread Django
#24891: Warn if referencing a template by the same name as one in an installed 
app
with higher precedence
-+--
 Reporter:  giuliettamasina  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Template system  |  Version:  master
 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 giuliettamasina):

 Replying to [comment:2 prestontimmons]:
 > I understand the confusion here, but the warning behavior is a little
 ambiguous. What if multiple loaders are defined? Or what if recursive
 inheritance is used? It's valid for an application to extend a template
 from another application with the same name.
 >
 > Some better solutions may be to:
 >
 > 1) Add logging in `django.template.loader` for `template.origin.name` so
 the full template paths can be logged to the console.
 >
 > 2) Use Django debug toolbar to see which template was used.

 I guess in the case of multiple loaders the check could be per loader or
 something like that. No warning would be emitted in the case of templates
 extending each other. However, of course this entire idea would need more
 work to handle various complex template scenarios. It might turn out to
 actually be an improvement to the documentation or such. But I've seen
 over and over developers rather new to Django run into this and I think
 there could be some improvement.

 Basically, you can have a template in your app and reference it, without
 there ever being a possibility of that template being used, unless you
 have read [https://docs.djangoproject.com/en/1.8/ref/settings/#installed-
 apps a specific sentence] in the documentation or otherwise know why.
 Logging and debugging of course help to figure this out, but I think we
 could make it even easier (and time efficient) by pointing it out to begin
 with, since we can probably know the occurrence of this case from just
 known facts about the current project/settings.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.a90ac288a40adbcedd7f74f59366cf18%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24891: Warn if referencing a template by the same name as one in an installed app with higher precedence

2015-06-01 Thread Django
#24891: Warn if referencing a template by the same name as one in an installed 
app
with higher precedence
-+--
 Reporter:  giuliettamasina  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Template system  |  Version:  master
 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 prestontimmons):

 I understand the confusion here, but the warning behavior is a little
 ambiguous. What if multiple loaders are defined? Or what if recursive
 inheritance is used? It's valid for an application to extend a template
 from another application with the same name.

 Some better solutions may be to:

 1) Add logging in `django.template.loader` for `template.origin.name` so
 the full template paths can be logged to the console.

 2) Use Django debug toolbar to see which template was used.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.ab288e60c931c3e8b88d3ffcabd4fc81%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24891: Warn if referencing a template by the same name as one in an installed app with higher precedence

2015-06-01 Thread Django
#24891: Warn if referencing a template by the same name as one in an installed 
app
with higher precedence
-+--
 Reporter:  giuliettamasina  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Template system  |  Version:  master
 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 timgraham):

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


Comment:

 I'm not sure it's feasible to implement. A template loading call would
 have to know the "current app" from where it's being called. Is there a
 clean way to get that information?

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.64dc0de13f9a05c8f5af8bb146e87e63%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #24891: Warn if referencing a template by the same name as one in an installed app with higher precedence

2015-06-01 Thread Django
#24891: Warn if referencing a template by the same name as one in an installed 
app
with higher precedence
-+
 Reporter:  giuliettamasina  |  Owner:  nobody
 Type:  New feature  | Status:  new
Component:  Template system  |Version:  master
 Severity:  Normal   |   Keywords:
 Triage Stage:  Unreviewed   |  Has patch:  0
Easy pickings:  0|  UI/UX:  0
-+
 Due to how precedence works when looking up templates, you can write an
 app that e.g. in one of its views references a template name in the same
 app, but that will never actually be used if one by the same name exists
 in another app that is listed earlier in `INSTALLED_APPS`.

 This can be quite a surprise and frustration if you are not aware of it,
 trying to debug why your template is not being used. The common solution
 is to have an additional subdirectory in the app template folder, named
 like the app itself. But you will have to find that out first, somehow.

 I'd suggest some kind of warning is emitted if an installed app is
 referencing a template name that also exists in another installed app with
 higher precedence. The warning would ideally only happen if that template
 actually exists in the app with lower precedence.

 What do you think?

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/058.475982a9ea20989d2dc0a90e61ba49c1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.