[Answered ]-Can you iterate through model fields when you overwrite the save() method in django?

1👍

Try this:

def save(self, *args, **kwargs):
   if self.text != "":
      results_dict = analyze(self.text)
      for field_name in field_names_list:
         setattr(self, field_name, results_dict[field_name])
   super().save(*args, **kwargs)

Leave a comment