2016-06-25 18:32:56 +02:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
class Book(models.Model):
|
|
|
|
title = models.CharField(max_length=50)
|
|
|
|
author = models.CharField(max_length=50)
|
|
|
|
pages = models.IntegerField(db_column="page_count")
|
2017-06-27 21:15:15 +02:00
|
|
|
shortcut = models.CharField(max_length=50, db_tablespace="idx_tbls")
|
|
|
|
isbn = models.CharField(max_length=50, db_tablespace="idx_tbls")
|
2019-07-05 14:15:41 +02:00
|
|
|
barcode = models.CharField(max_length=31)
|
2017-03-17 16:25:12 +01:00
|
|
|
|
2017-06-07 16:13:12 +02:00
|
|
|
class Meta:
|
2017-09-17 08:26:18 +02:00
|
|
|
indexes = [
|
2019-07-08 14:11:50 +02:00
|
|
|
models.Index(fields=["title"]),
|
|
|
|
models.Index(fields=["isbn", "id"]),
|
2019-07-05 14:15:41 +02:00
|
|
|
models.Index(
|
|
|
|
fields=["barcode"], name="%(app_label)s_%(class)s_barcode_idx"
|
|
|
|
),
|
2017-09-17 08:26:18 +02:00
|
|
|
]
|
2017-06-07 16:13:12 +02:00
|
|
|
|
2017-03-17 16:25:12 +01:00
|
|
|
|
|
|
|
class AbstractModel(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
2019-07-05 14:15:41 +02:00
|
|
|
shortcut = models.CharField(max_length=3)
|
2017-03-17 16:25:12 +01:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
2019-07-05 14:15:41 +02:00
|
|
|
indexes = [
|
|
|
|
models.Index(fields=["name"]),
|
|
|
|
models.Index(fields=["shortcut"], name="%(app_label)s_%(class)s_idx"),
|
|
|
|
]
|
2017-03-17 16:25:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ChildModel1(AbstractModel):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ChildModel2(AbstractModel):
|
|
|
|
pass
|