sanic/examples/asyncorm/library/models.py

25 lines
581 B
Python
Raw Normal View History

from asyncorm import models
2017-03-27 22:47:35 +01:00
BOOK_CHOICES = (
('hard cover', 'hard cover book'),
('paperback', 'paperback book')
)
# This is a simple model definition
class Book(models.Model):
name = models.CharField(max_length=50)
synopsis = models.CharField(max_length=255)
book_type = models.CharField(
max_length=15,
null=True,
choices=BOOK_CHOICES
)
pages = models.IntegerField(null=True)
date_created = models.DateField(auto_now=True)
2017-03-27 22:47:35 +01:00
class Meta():
ordering = ['-name', ]
2017-03-27 22:47:35 +01:00
unique_together = ['name', 'synopsis']