2016-06-26 00:32:56 +08: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-03-17 23:25:12 +08:00
|
|
|
|
2017-06-07 22:13:12 +08:00
|
|
|
class Meta:
|
|
|
|
indexes = [models.indexes.Index(fields=['title'])]
|
|
|
|
|
2017-03-17 23:25:12 +08: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
|