There's way to change "model_list" result variable name from ListView?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

There's way to change "model_list" result variable name from ListView?

fellipeh
Hi,

Normal ListView result a list with "model"_list  as name... there's any way to change these name?


T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF1jwZEEngEz-v%2BCwyURRQ4FD-JisKo4ZVggVJhsjGrjLZpxNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: There's way to change "model_list" result variable name from ListView?

gamesbook
You question is not very clear; perhaps add some code and/or screenshots to show what you mean.

On Wednesday, 31 October 2018 14:51:15 UTC+2, Fellipe Henrique wrote:
Hi,

Normal ListView result a list with "model"_list  as name... there's any way to change these name?


T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Fedora Ambassador: <a href="https://fedoraproject.org/wiki/User:Fellipeh" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ffedoraproject.org%2Fwiki%2FUser%3AFellipeh\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHjCGLxijKP9MQZCTlXQ2iMRoV8w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ffedoraproject.org%2Fwiki%2FUser%3AFellipeh\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHjCGLxijKP9MQZCTlXQ2iMRoV8w&#39;;return true;">https://fedoraproject.org/wiki/User:Fellipeh
Blog: <a href="http:www.fellipeh.eti.br" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http:www.fellipeh.eti.br&#39;;return true;" onclick="this.href=&#39;http:www.fellipeh.eti.br&#39;;return true;">http:www.fellipeh.eti.br
GitHub: <a href="https://github.com/fellipeh" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ffellipeh\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGOWbt4nIiKGXdAnmi8I-_lFKDU8Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ffellipeh\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGOWbt4nIiKGXdAnmi8I-_lFKDU8Q&#39;;return true;">https://github.com/fellipeh
Twitter: @fh_bash

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4aa47584-941a-426f-8b25-b64ae246b275%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: There's way to change "model_list" result variable name from ListView?

Daniel Roseman-2
In reply to this post by fellipeh
On Wednesday, 31 October 2018 12:51:15 UTC, Fellipe Henrique wrote:
Hi,

Normal ListView result a list with "model"_list  as name... there's any way to change these name?



You can set `context_object_name` to whatever name you want. 

This is documented here: https://docs.djangoproject.com/en/2.1/topics/class-based-views/generic-display/#making-friendly-template-contexts
-- 
DR.
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/abf4b557-63f6-430f-8a35-05a1497c6ab0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.