【发布时间】:2013-03-19 03:36:11
【问题描述】:
我正在像这样在 django 模型构造函数中设置默认值
class Student(models.Model):
name = models.TextField()
location = models.TextField()
def __init__(self, *args, **kwargs):
self.location="sample"
super(Student, self).__init__(*args, **kwargs)
现在我排除了管理表单中的位置字段。 但是如果在 StudentAdmin 中这样做
def save_model(self, request, obj, form, change):
raise Exception(obj.location)
然后commig为空
【问题讨论】:
-
发布
StudentAdmin的代码