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
Call all()
to retrieve the elements from the manager.
{% for area in world_areas.all %}
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.
I run into this issue by a reckless mistake:
for physicalserver in task.physicalservers:
physicalserver.relieve_task()
The task.physicalservers
is RelatedManager
object, in my case I should get the task's physicalservers, there should add .all()
.
for physicalserver in task.physicalservers.all():