【发布时间】:2011-07-12 21:41:21
【问题描述】:
我有以下Bank 模型:
from django.db import models
class Bank(models.Model):
id = models.BigIntegerField(primary_key=True)
name = models.CharField(unique=True, max_length=255)
identifier = models.CharField(unique=True, max_length=255)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
class Meta:
db_table = u'bank'
app_name = 'mcif'
现在看看这个:
>>> from mcif.models import *
>>> b = Bank()
>>> b.name = "wee"
>>> b.identifier = "wee"
>>> b.save()
>>> b.id
>>>
如果我了解 Django 的工作原理,Bank 对象应该会使用已保存记录的 id 进行更新。知道为什么这没有发生吗?
【问题讨论】:
标签: django django-models