"Variables and attributes may not begin with underscores" error

1,371 views
Skip to first unread message

Raffaele Salmaso

unread,
Jun 29, 2018, 5:28:41 PM6/29/18
to django-d...@googlegroups.com
Hi,
anyone knows the rationale for forbidding variables and attributes with an initial underscore in django templates?
This limitation is here from day 0 
and docs doesn't mention it (or simply I can't google it)

I've removed this check and it seem fine for the empirical tests

If there is no objection would be ok to remove this limitation?

Thaks

--

Gregory Kaleka

unread,
Jun 29, 2018, 6:44:56 PM6/29/18
to Django developers (Contributions to Django itself)
The docs do mention it on the more complete template api page, though there isn't an explanation as to the reason. I would say it should at least be added to the template docs you link to.

Tim Graham

unread,
Jun 30, 2018, 7:27:46 PM6/30/18
to Django developers (Contributions to Django itself)
I think the reason is that underscore-prefixed attributes are generally considered to be private. Accessing them in templates doesn't seem like good practice.
Reply all
Reply to author
Forward
0 new messages