2016-06-25 22:02:56 +05:30
|
|
|
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')
|
2017-03-17 11:25:12 -04:00
|
|
|
|
2017-06-07 07:13:12 -07:00
|
|
|
class Meta:
|
2017-09-17 08:26:18 +02:00
|
|
|
indexes = [
|
|
|
|
models.indexes.Index(fields=['title']),
|
|
|
|
models.indexes.Index(fields=['isbn', 'id']),
|
|
|
|
]
|
2017-06-07 07:13:12 -07:00
|
|
|
|
2017-03-17 11:25:12 -04:00
|
|
|
|
|
|
|
class AbstractModel(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
indexes = [models.indexes.Index(fields=['name'])]
|
|
|
|
|
|
|
|
|
|
|
|
class ChildModel1(AbstractModel):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ChildModel2(AbstractModel):
|
|
|
|
pass
|