django choices model field code example

Example: django models choices example

from django.db import models

class Author(models.Model):
   first_name = models.CharField(max_length=64)
   last_name = models.CharField(max_length=64)

   def __str__(self):
       return '{} {}'.format(self.first_name, self.last_name)


class Book(models.Model):
   author = models.ForeignKey('books.Author', related_name='books', on_delete=models.CASCADE)
   title = models.CharField(max_length=128)
   status = models.CharField(
       max_length=32,
       choices=[],  # some list of choices
   )

   def __str__(self):
       return '{}: {}'.format(self.author, self.title)