Why can't templates access properties

104 views
Skip to first unread message

Ram Rachum

unread,
May 26, 2015, 2:27:40 PM5/26/15
to django-d...@googlegroups.com
Hi,

I noticed that when I use variables in Django templates that access object properties, it doesn't work. (e.g. I have {{ foo.bar }} while bar is a Python property.)

See the documentation for variables in Django templates:


It indeed doesn't mention properties.

Why should properties not work through template? I can't think of a good reason. 


Thanks,
Ram.

Tim Graham

unread,
May 26, 2015, 3:19:25 PM5/26/15
to django-d...@googlegroups.com
Accessing properties in templates should work as far as I know. Maybe there is an error in your application.

Ram Rachum

unread,
May 26, 2015, 5:14:49 PM5/26/15
to django-d...@googlegroups.com
I found the cause of my problem: `django.db.models.Manager.from_queryset` copies all the methods from the `QuerySet` class to the `Manager` class, but it doesn't copy the properties.

What do you think about opening an issue for making `django.db.models.Manager.from_queryset` copy over properties as well? 

Curtis Maloney

unread,
May 26, 2015, 7:56:49 PM5/26/15
to django-d...@googlegroups.com
Feel free to open a ticket, as it will give a place to retain the discussion.

Perhaps start with the use case for having additional properties on a QuerySet :)

--
Curtis

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/7188bfd5-632d-4333-868f-180540a8193c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ram Rachum

unread,
May 27, 2015, 4:17:52 AM5/27/15
to django-developers

--
You received this message because you are subscribed to a topic in the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-developers/e6SOZNs0GVU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-develop...@googlegroups.com.

To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
Reply all
Reply to author
Forward
0 new messages