'RelatedManager' object is not iterable Django

前端 未结 3 2072
轮回少年
轮回少年 2020-12-10 00:52

Hey i have looked around through some simliar posts here on SO but havent found anything that has solved my problem. I have the following models,

from django         


        
3条回答
  •  囚心锁ツ
    2020-12-10 01:07

    In general, it is better practice to use a values or values_list to pass data from a queryset to a template.

    world_areas = Areas.objects.select_related().all().values_list('name', 'order_in_sidebar_network', ...)
    

    Check out the Django docs for info on how to use the values function if you haven't used it before.

提交回复
热议问题