小编Ali*_*han的帖子

在Django模型中继承元类

我有一个问题作为新手,我正在寻找与Django类中继承Meta类相关的概念.以下是模型,如果有人可以帮助我,我将不胜感激.

class Base(models.Model):
    code = AutoSlugField(_("Slug"), max_length=128, unique=True,
                         populate_from='name')
    name = models.CharField(_("Name"), max_length=128, unique=True)
    description = models.TextField(_("Description"), blank=True)
    countries = models.ManyToManyField('Country',
                                       blank=True, verbose_name=_("Countries"))
    is_discounted = False
    class Meta:
        app_label = 'shipping'
        ordering = ['name']
        verbose_name = _("Shipping Method")
        verbose_name_plural = _("Shipping Methods")


class OrderAndItemCharges(Base):
    price_per_order = models.DecimalField(
        _("Price per order"), decimal_places=2, max_digits=12,
        default=D('0.00'))
    price_per_item = models.DecimalField(
        _("Price per item"), decimal_places=2, max_digits=12,
        default=D('0.00'))
    free_shipping_threshold = models.DecimalField(
        _("Free Shipping"), decimal_places=2, max_digits=12, blank=True,
        null=True)
    class Meta(Base.Meta):
        app_label = 'shipping'
        verbose_name = _("Order and …
Run Code Online (Sandbox Code Playgroud)

python django

9
推荐指数
1
解决办法
6846
查看次数

标签 统计

django ×1

python ×1