赞
踩
执行python manage makemigrations OnlineUpgrade时,报如下错误:
- <span style="color:#ff6666;">D:\KLServer\pycode\KLServer>python manage.py makemigrations OnlineUpgrade
- SystemCheckError: System check identified some issues:
-
-
- ERRORS:
- OnlineUpgrade.SoftwareUpgradeRecord.high_version: (fields.E304) Reverse accessor for 'SoftwareUpgradeRecord.high_version' clashes with reverse accessor for 'SoftwareVersionDiff.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareUpgradeRecord.high_version' or 'SoftwareVersionDiff.high_version'.
- OnlineUpgrade.SoftwareUpgradeRecord.high_version: (fields.E304) Reverse accessor for 'SoftwareUpgradeRecord.high_version' clashes with reverse accessor for 'SubSoftwareKitVersionDiff.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareUpgradeRecord.high_version' or 'SubSoftwareKitVersionDiff.high_version'.
- OnlineUpgrade.SoftwareUpgradeRecord.high_version: (fields.E305) Reverse query name for 'SoftwareUpgradeRecord.high_version' clashes with reverse query name for 'SoftwareVersionDiff.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareUpgradeRecord.high_version' or 'SoftwareVersionDiff.high_version'.
- OnlineUpgrade.SoftwareUpgradeRecord.high_version: (fields.E305) Reverse query name for 'SoftwareUpgradeRecord.high_version' clashes with reverse query name for 'SubSoftwareKitVersionDiff.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareUpgradeRecord.high_version' or 'SubSoftwareKitVersionDiff.high_version'.
- OnlineUpgrade.SoftwareUpgradeRecord.low_version: (fields.E304) Reverse accessor for 'SoftwareUpgradeRecord.low_version' clashes with reverse accessor for 'SoftwareVersionDiff.low_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareUpgradeRecord.low_version' or 'SoftwareVersionDiff.low_version'.
- OnlineUpgrade.SoftwareUpgradeRecord.low_version: (fields.E305) Reverse query name for 'SoftwareUpgradeRecord.low_version' clashes with reverse query name for 'SoftwareVersionDiff.low_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareUpgradeRecord.low_version' or 'SoftwareVersionDiff.low_version'.
- OnlineUpgrade.SoftwareVersionDiff.high_version: (fields.E304) Reverse accessor for 'SoftwareVersionDiff.high_version' clashes with reverse accessor for 'SoftwareUpgradeRecord.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareVersionDiff.high_version' or 'SoftwareUpgradeRecord.high_version'.
- OnlineUpgrade.SoftwareVersionDiff.high_version: (fields.E304) Reverse accessor for 'SoftwareVersionDiff.high_version' clashes with reverse accessor for 'SubSoftwareKitVersionDiff.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareVersionDiff.high_version' or 'SubSoftwareKitVersionDiff.high_version'.
- OnlineUpgrade.SoftwareVersionDiff.high_version: (fields.E305) Reverse query name for 'SoftwareVersionDiff.high_version' clashes with reverse query name for 'SoftwareUpgradeRecord.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareVersionDiff.high_version' or 'SoftwareUpgradeRecord.high_version'.
- OnlineUpgrade.SoftwareVersionDiff.high_version: (fields.E305) Reverse query name for 'SoftwareVersionDiff.high_version' clashes with reverse query name for 'SubSoftwareKitVersionDiff.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareVersionDiff.high_version' or 'SubSoftwareKitVersionDiff.high_version'.
- OnlineUpgrade.SoftwareVersionDiff.low_version: (fields.E304) Reverse accessor for 'SoftwareVersionDiff.low_version' clashes with reverse accessor for 'SoftwareUpgradeRecord.low_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareVersionDiff.low_version' or 'SoftwareUpgradeRecord.low_version'.
- OnlineUpgrade.SoftwareVersionDiff.low_version: (fields.E305) Reverse query name for 'SoftwareVersionDiff.low_version' clashes with reverse query name for 'SoftwareUpgradeRecord.low_version'.
- HINT: Add or change a related_name argument to the definition for 'SoftwareVersionDiff.low_version' or 'SoftwareUpgradeRecord.low_version'.
- OnlineUpgrade.SubSoftwareKitVersionDiff.high_version: (fields.E304) Reverse accessor for 'SubSoftwareKitVersionDiff.high_version' clashes with reverse accessor for 'SoftwareUpgradeRecord.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SubSoftwareKitVersionDiff.high_version' or 'SoftwareUpgradeRecord.high_version'.
- OnlineUpgrade.SubSoftwareKitVersionDiff.high_version: (fields.E304) Reverse accessor for 'SubSoftwareKitVersionDiff.high_version' clashes with reverse accessor for 'SoftwareVersionDiff.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SubSoftwareKitVersionDiff.high_version' or 'SoftwareVersionDiff.high_version'.
- OnlineUpgrade.SubSoftwareKitVersionDiff.high_version: (fields.E305) Reverse query name for 'SubSoftwareKitVersionDiff.high_version' clashes with reverse query name for 'SoftwareUpgradeRecord.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SubSoftwareKitVersionDiff.high_version' or 'SoftwareUpgradeRecord.high_version'.
- OnlineUpgrade.SubSoftwareKitVersionDiff.high_version: (fields.E305) Reverse query name for 'SubSoftwareKitVersionDiff.high_version' clashes with reverse query name for 'SoftwareVersionDiff.high_version'.
- HINT: Add or change a related_name argument to the definition for 'SubSoftwareKitVersionDiff.high_version' or 'SoftwareVersionDiff.high_version'.</span>
原来的模型代码:
- @python_2_unicode_compatible
- class SoftwareVersionDiff(models.Model):
- '''
- 软件版本差分
- '''
-
- # 软件
- software = models.ForeignKey(to=Software, verbose_name='软件')
-
- # 低版本
- low_version = models.ForeignKey(to=Version,
- related_name='low_version', verbose_name='低版本')
-
- # 高版本
- high_version = models.ForeignKey(to=Version,
- related_name='high_version', verbose_name='高版本')
-
-
- @python_2_unicode_compatible
- class SubSoftwareKitVersionDiff(models.Model):
- '''
- 软件子集版本差分
- '''
-
- # 软件子集
- subsoftwarekit = models.ForeignKey(to=SubSoftwareKit, verbose_name='软件子集')
-
-
- # 低版本
- low_version = models.ForeignKey(to=Version,
- related_name='low_versin_subsoftware', verbose_name='低版本')
-
- # 高版本
- high_version = models.ForeignKey(to=Version,
- related_name='high_version',verbose_name='高版本')
-
-
- @python_2_unicode_compatible
- class SoftwareUpgradeRecord(models.Model):
- '''
- 软件更新记录,记录更新过程
- 这里特别需要注意的是,一次更新请求中可能会有许多的软件需要更新,这个时候一次请求,可能会
- 触发多次更新记录,因为每个软件更新的(低版本->高版本)是不一样的。
- '''
- # 更新的所有软件
- softwares = models.CharField(verbose_name='软件', max_length=2048, null=False)
-
- # 低版本
- low_version = models.ForeignKey(to=Version,
- related_name='low_version', verbose_name='低版本')
-
- # 高版本
- high_version = models.ForeignKey(to=Version,
- related_name='high_version', verbose_name='高版本')
解决方案:将同一个表中的releated_name,全部修改,指定不一样的releated_name
修改后的代码
- @python_2_unicode_compatible
- class SoftwareVersionDiff(models.Model):
- '''
- 软件版本差分
- '''
-
- # 软件
- software = models.ForeignKey(to=Software, verbose_name='软件')
-
- # 低版本
- low_version = models.ForeignKey(to=Version,
- related_name='low_version_software_version_diff', verbose_name='低版本')
-
- # 高版本
- high_version = models.ForeignKey(to=Version,
- related_name='high_version_software_version_diff', verbose_name='高版本')
-
-
- @python_2_unicode_compatible
- class SubSoftwareKitVersionDiff(models.Model):
- '''
- 软件子集版本差分
- '''
-
- # 软件子集
- subsoftwarekit = models.ForeignKey(to=SubSoftwareKit, verbose_name='软件子集')
-
-
- # 低版本
- low_version = models.ForeignKey(to=Version,
- related_name='low_versin_subsoftware_version_diff', verbose_name='低版本')
-
- # 高版本
- high_version = models.ForeignKey(to=Version,
- related_name='high_version_subsoftware_version_diff',verbose_name='高版本')
-
-
- @python_2_unicode_compatible
- class SoftwareUpgradeRecord(models.Model):
- '''
- 软件更新记录,记录更新过程
- 这里特别需要注意的是,一次更新请求中可能会有许多的软件需要更新,这个时候一次请求,可能会
- 触发多次更新记录,因为每个软件更新的(低版本->高版本)是不一样的。
- '''
- # 更新的所有软件
- softwares = models.CharField(verbose_name='软件', max_length=2048, null=False)
-
- # 低版本
- low_version = models.ForeignKey(to=Version,
- related_name='low_version_software_upgrade_record', verbose_name='低版本')
-
- # 高版本
- high_version = models.ForeignKey(to=Version,
- related_name='high_version_software_upgrade_record', verbose_name='高版本')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。