How To Create Django Form Choice List From Query In View?
I have a Django form where I would like to use dynamic choice list from a query in my view. Here is what I'm trying to do: views.py getdata = MyModel.objects.filter(filter=filter)
Solution 1:
choice
is the individual item in each iteration, not getdata
.
mylist=[( (choice.id), (choice.name) ) for choice in getdata]
Post a Comment for "How To Create Django Form Choice List From Query In View?"