Hi All,

I recently discovered that there is no way in the Django template syntax to 
access all valid items of a dict. For example, as I understand it, it is 
impossible to access the only item of this dict:

my_dict = {"_key": "value"}

This is despite this dict being perfectly valid and not breaking any Python 
conventions. I also discovered that possible work arounds like this 
ticket<https://code.djangoproject.com/ticket/3371> have 
been set to won't fix because they are considered to be out "out of scope 
for the built-in template engine".

I'd like to request that this issue be re-examined. It 
is extremely frustrating not being able to access perfectly legal dict 
items by key using the Django template engine. One possible reason for 
the preceding _ rule also applying to dict lookups in the variable syntax 
mentioned on IRC was to make it simpler for template coders who have no 
real knowledge of Python (and the convention that variables or functions 
prefixed with _ are considered private). I can't see how enforcing this 
rule makes it any simpler for them especially since it isn't actually 
mentioned in the template syntax documentation and generally these people 
wouldn't be constructing the context for the template in the view. All it 
really seems to do is add more complexity for the view programers without 
any real increase in simplicity for template writers who are blissfully 
unaware.

Interested to hear the reasoning behind the original design decision and 
how people are finding it in practice.

Cheers


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/M9R3QeNaFs0J.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to