example-of-crud-in-django-w.../app/library/models.py

21 lines
542 B
Python
Raw Normal View History

2021-07-14 16:19:03 +02:00
# app/Library/models.py
2021-07-09 19:09:31 +02:00
from django.db import models
2021-07-05 15:56:53 +02:00
2021-07-14 16:19:03 +02:00
class Book(models.Model):
2021-07-09 19:09:31 +02:00
title = models.CharField(max_length=255)
2021-07-14 16:46:34 +02:00
country = models.CharField(max_length=255)
2021-07-09 19:09:31 +02:00
year = models.CharField(max_length=4)
author = models.CharField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
2021-07-14 16:19:03 +02:00
ordering = ("created_at",)
verbose_name = "Book"
verbose_name_plural = "Books"
2021-07-09 19:09:31 +02:00
def __str__(self):
2021-07-13 18:30:31 +02:00
return self.title