Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django南迁导致关键错误:u';名称';_Django_Django South - Fatal编程技术网

Django南迁导致关键错误:u';名称';

Django南迁导致关键错误:u';名称';,django,django-south,Django,Django South,键错误:u'name' 以下是相关型号,完整的models.py可供使用: 我 在这个模型中,我只想添加一个已经注释掉的字段 没有添加字段的第一次迁移可以正常进行。但是第二次迁移时字段发生了变化,这就产生了错误。我做错了什么 添加更多此问题发生在南方0.7.3。请将其升级到south 0.8。这将解决问题 您正在执行哪个命令?对于south,第一次迁移必须执行“-initial”,下一次迁移必须执行“-auto”。此外,有时,您会在第一次迁移时更改数据库,并且(如果您没有数据库信息),我建议您删

键错误:u'name'

以下是相关型号,完整的models.py可供使用:

我 在这个模型中,我只想添加一个已经注释掉的字段

没有添加字段的第一次迁移可以正常进行。但是第二次迁移时字段发生了变化,这就产生了错误。我做错了什么


添加更多

此问题发生在南方0.7.3。请将其升级到south 0.8。这将解决问题

您正在执行哪个命令?对于south,第一次迁移必须执行“-initial”,下一次迁移必须执行“-auto”。此外,有时,您会在第一次迁移时更改数据库,并且(如果您没有数据库信息),我建议您删除所有表并重新进行迁移。还有另一个名为convert_to_south的命令,它执行您所说的操作。然后第二个命令是--auto
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)