aren't instances of class iterable in python as it is possible in java ,.,
class User(models.Model):
first_name = models.CharField(max_length=50)
ref_num = models.IntegerField()
ref_list = [2,3]
user_list = [User(first_name='abc',ref_num=1)]
for ref in ref_list:
user_list.extend(User(first_name='abc',ref_num=ref))
but getting error as :
TypeError 'User' object is not iterable
.appendnot.extend...extendtakes the contents of a list, item for item, andappends them to another list.appendadds an item to the end of a list. Therefore,extendexpects to get alistlikeas its input, whereasappendwill take anything.