I am beginner in Django and Currently I was developing the code in Django and was not able to figure out the difference between the two.
class MyForm(forms.Form):
myfield = forms.ChoiceField(choices=[(u.id, u.username) for u in User.objects.filter(type="TYPE1")])
and
class MyForm(forms.Form):
pass
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.fields['myfield'] = forms.ChoiceField(choices=[(u.id, u.username) for u in User.objects.filter(type="TYPE1")])
even though purpose of both code is same but I am unable to spot the difference between the two as what is going on behind the scene.