django-rest-frameworkmodelchoicefield

How can I use choice_fields in my models.py file and how to represent them in my output?


I'm trying to include an attribute in models named as 'action' to show the action status of particular todo items. And for that I've tried to create these files but its not working as per my requirements.

I expected a dropdown or checkboxes but didn't get them yet.


Solution

  • you can create using charfields

    class Model:
      choices = (
        (a, a),
         (b,b)
      )
     choice = models.charField(choices=choices )