0

I would like to display certain fields for all objects of a model in a table. And I also want to render the url property of some FileFields, which are part of that model.

So, I got models with obj_data = ThatObject.objects.only('field1', 'field2', 'field3')

But I do not know how to access everything in the template. I could say {% for single_object in obj_data %}, but I cannot iterate over the fields of single_object. How can I do that?

MDoe
  • 163
  • 1
  • 13
  • see https://stackoverflow.com/questions/2170228/iterate-over-model-instance-field-names-and-values-in-template – Ben May 08 '20 at 21:46
  • Thanks. I am somewhat confused that there is no simple option to iterate over a model. I do not know about getattr and so, but I guess I am about to find out. – MDoe May 09 '20 at 08:05

0 Answers0