我有以下4列我想添加到所有表中:
目前我的方式如下:
from django.db import models
class Table_1(models.Model):
column1 = models.CharField(max_length=64)
column2 = models.CharField(max_length=64)
creationname = models.CharField(max_length=64)
creationdate = models.DateTimeField('creation date', auto_now_add=False)
revisionname = models.CharField(max_length=64)
revisiondate = models.DateTimeField('revision date', auto_now=False)
class Table_2(models.Model):
column1 = models.CharField(max_length=64)
column2 = models.CharField(max_length=64)
creationname = models.CharField(max_length=64)
creationdate = models.DateTimeField('creation date', auto_now_add=False)
revisionname = models.CharField(max_length=64)
revisiondate = models.DateTimeField('revision date', auto_now=False)
...
class Table_n(models.Model):
column1 = models.CharField(max_length=64)
column2 = models.CharField(max_length=64)
creationname = models.CharField(max_length=64)
creationdate = models.DateTimeField('creation date', auto_now_add=False)
revisionname = models.CharField(max_length=64)
revisiondate = models.DateTimeField('revision date', auto_now=False)
这可以通过自动方式实现,因此4列会自动附加到每个表中吗? 注意:对于django项目的所有表格而言,这是否也可以实现,而不仅仅是单个django应用程序的表格?
如果这是针对django设计理念,请告诉我