使用python 3的Django抽象模型中的相关名称

时间:2014-09-20 11:55:21

标签: django python-3.x django-models

当我使用Python3.4在相关名称中使用%(app_label)s_%(class)s时出现以下错误

    'app_label': cls._meta.app_label.lower()
TypeError: unsupported operand type(s) for %: 'bytes' and 'dict'

还有另一种方法吗?

修改

class TimeStampModel(models.Model):     

    modified = models.DateTimeField(auto_now=True)
    created = models.DateTimeField(auto_now_add=True)

    created_by = models.ForeignKey(User, related_name = "%(app_label)s_%(class)s_created_by" ,)
    edited_by =  models.ForeignKey(User, related_name = "%(app_label)s_%(class)s_edited_by" ,  blank=True, null=True)

    class Meta:
        abstract = True

0 个答案:

没有答案