I have the following in my models.py:
class HostData(models.Model):
Manager = models.ForeignKey(Managers)
Host = models.CharField(max_length=50, null=True)
HostStatus = models.CharField(max_length=200, null=True)
Cpu = models.PositiveIntegerField(max_length=10, null=True)
Disk = models.FloatField(null=True)
I would like to return the query for objects related to a certain "Manager". The problem is that the user may add/delete as many managers as he wants. So my initial thought was to have in my views.py something like this:
def get_data(request):
for server in Managers.objects.all():
host_data = HostData.objects.filter(Manager=server)
# Lost after this :(
return render_to_response('mypage.html', {'first_set': host_data1, 'second_set': host_data2})
So, how can I return multiple objects? Like if the user adds another "Manager" I'll get a third set in my views.py.