KeyError:u'name'。
以下是相关模型,完整的models.py可用here:
from django.db import models
from django.contrib.auth.models import User
from sorl.thumbnail import ImageField
import string,random,datetime
class Property(models.Model):
name = models.CharField(max_length = 200)
inspected_by = models.ForeignKey(User,null = True, blank = True)
#inspection_date = models.CharField(max_length = 200,null=True,blank = True)
lease = models.ForeignKey('PropertyLease')
occupancy = models.ForeignKey('PropertyOccupancy')
owner = models.ForeignKey('PropertyOwner')
property_type = models.ForeignKey('PropertyType')
cost = models.ForeignKey('PropertyCost', null = True, blank = True)
floor_plate_area = models.IntegerField(null = True,blank = True, verbose_name="Total floor plate area (In sqft)")
total_available_area = models.IntegerField(null = True,blank = True, verbose_name="Total available area (In sqft)")
special_note = models.TextField(null = True, blank = True)
residential = models.BooleanField(default=False)
commercial = models.BooleanField(default = False)
is_active = models.BooleanField(default=True)
datetime = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(null = True, blank = True)
def save(self,*args, **kwargs):
self.last_updated = datetime.datetime.now()
if (self.is_active == False):
if(self.property_type.name=="Building"):
bld = PropertyBuilding.objects.get(property=self)
floors = PropertyFloor.objects.filter(building=bld)
for floor in floors:
units = PropertyUnit.objects.filter(floor=floor)
floor.property.is_active=False
floor.property.save()
for unit in units:
unit.property.is_active=False
unit.property.save()
if (self.property_type.name=="SEZ"):
blds = PropertyBuilding.objects.filter(parcel__estate=self)
for bld in blds:
floors = PropertyFloor.objects.filter(building=bld)
bld.property.save()
for floor in floors:
units = PropertyUnit.objects.filter(floor=floor)
floor.property.save()
for unit in units:
unit.property.save()
elif (self.property_type.name=="Building"):
floors = PropertyFloor.objects.filter(building=self)
for floor in floors:
units = PropertyUnit.objects.filter(floor=floor)
floor.property.save()
for unit in units:
unit.property.save()
elif (self.property_type.name=="Floor"):
units = PropertyUnit.objects.filter(floor=self)
for unit in units:
unit.property.save()
super(Property, self).save(*args, **kwargs)
我 在这个模型中,我只想添加一个已被注释掉的字段。
没有添加字段的第一次迁移很顺利。但是,使用字段更改进行的第二次迁移会产生错误。我做错了什么?
再添加一些traceback
答案 0 :(得分:1)
此问题发生在南0.7.3。请将其升级到0.8以南。它将解决问题。