I have these models:
class BillHeader(models.Model): billno = models.IntegerField(primary_key=True, blank=True) class BillData(models.Model): price = models.DecimalField(_('Price'), max_digits=12, decimal_places=2) amount = models.DecimalField(_('Amount'), max_digits=6, decimal_places=2) [... rest of the model ...] class Meta: abstract = True class BillFooter(models.Model): total = models.DecimalField(_('Total'), max_digits=12, decimal_places=2) [... rest of the model ...] class Meta: abstract = True
BillDataand BillFooterare common to all BillHeader, so I marked them as abstract. Can I do class BillHeader(BillData, BillFooter)or am I doing something wrong?
BillData
BillFooter
BillHeader
abstract
class BillHeader(BillData, BillFooter)
I also thought about making BillDatabasic, and BillHeader BillFooterabstract. I have no experience with data models (at least not complicated), and I got a little lost. What would you recommend?
, Django , , " ". ... , , . - .
, models.Model, , models.Model Bill. models.Model , .
models.Model
Bill
, , Bill, BillHeader, BillData BillFooter. , Django (, Bill, Article, BlogPost, Photo ..).
, , , . , . , , Bill, UnpaidBill PaidBill... , , , ABC.
, , ABC .
Source: https://habr.com/ru/post/1752331/More articles:Parent / child hierarchy / "Nested sets", in Python / Django - pythonHow to create a file on a remote host with creating a directory using ssh - fileuse if-else logic in where where in T-SQL - sql-serverasp.net membership - sql authentication - sqlPreventing resubmission of a view when updating a browser - php calls the vertical scroll bar in IE. Why / how to avoid this? - htmlJavascript bounding box calculation - javascriptИспользование Cocos2d в одном окне iPhone - iphoneperl - file processing - directoryCookie does not work in IE - internet-explorerAll Articles