这是带有回溯的更新代码
这是模型:
class Base(models.Model):
created_by = models.ForeignKey(User, related_name="(app_label)s_%(class)s_creator")
edited_by = models.ForeignKey(User, related_name="(app_label)s_%(class)s_editor")
created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
class Department(Base):
dept_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=60, unique=True)
description = models.TextField()
def __unicode__(self):
return str(self.name)
错误回溯:
ValueError Traceback (最近一次调用最后一次)
C:\python27\lib\site-packages\django-1.5-py2.7.egg\django\core\management\commands\shell.pyc in () ---- > 1 测试 = Department.objects.create(name='test',description='test')
C:\python27\lib\site-packages\django-1.5-py2.7.egg\django\db\models\fields\__init__.pyc in get_prep_value(se
lf, value)
553 if value is None:
554 return None
--> 555 return int(value)
556
557 def contribute_to_class(self, cls, name):
ValueError: invalid literal for int() with base 10: '<property object at 0x000000000332AB38>'