Skip to content

Instantly share code, notes, and snippets.

@cicorias
Created June 3, 2020 22:48
Show Gist options
  • Save cicorias/36f83b8caa18ffe0436eb5334f1752dc to your computer and use it in GitHub Desktop.
Save cicorias/36f83b8caa18ffe0436eb5334f1752dc to your computer and use it in GitHub Desktop.
using choice fields
from django.db import models
class BakedGood(models.Model):
name = models.CharField(max_length=64)
desc = models.CharField(max_length=256)
good_type = models.TextChoices('type', 'BAGEL BREAD COOKIE CAKE PRETZEL')
sTypes = models.CharField(blank=True, choices=good_type.choices, max_length=20)
price = models.DecimalField(max_digits=6, decimal_places=2)
recipe = models.TextField()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment