我想在我的开发环境中从Django 1.7.1升级到1.8。我似乎遇到了我的一个模型的问题,我认为核心文件已经升级并且弄乱了我的模型。我似乎无法弄清楚是什么导致它死亡。
这是我尝试运行manage.py测试时遇到的唯一错误
CommandError: System check identified some issues:
ERRORS:
graphite_alerts.CheckResults: (models.E020) The 'CheckResults.check()' class method is currently overridden by <django.db.models.fields.related.ReverseSingleRelatedObjectDescriptor object at 0x3a76310>.
我尝试更改类名并查看我的模型并且似乎无法找到任何会导致覆盖错误的内容
这是班级:
class CheckResults(models.Model):
WARN = 'warn'
ERROR = 'error'
OK = 'ok'
DOWN = 'down'
STATUS_CHOICES = (
(WARN, 'Warn'),
(ERROR, 'Error'),
(OK, 'OK'),
(DOWN, 'Down'),
)
target = models.CharField(max_length=1000)
additional_graph_target = models.CharField(max_length=1000, blank=True)
value = models.DecimalField(max_digits=9, decimal_places=2)
timestamp = models.DateTimeField(db_index=True)
status = models.CharField(max_length=6, choices=STATUS_CHOICES, default='ok')
check = models.ForeignKey(Check, related_name='results')
tags = TaggableManager()
def __unicode__(self):
return self.target
@models.permalink
def get_absolute_url(self):
return ('graphite-check-result-list-view', (), {'pk': self.check.pk, 'target': self.target})
def generate_graphite_image_url(self):
params = { }
params['target'] = []
params['target'].append(self.target)
params['target'].append('threshold(' + str(self.check.warn) + ',"Warn","yellow")')
params['target'].append('threshold(' + str(self.check.error) + ',"Error","red")')
params['from'] = '-7days'
params['width'] = '900'
params['minorGridLineColor'] = 'C0C0C0'
params['majorGridLineColor'] = 'C0C0C0'
params['bgcolor'] = '333333'
request = requests.get(self.check.GRAPHITE_URL+self.check.RENDER_PAGE,params=params)
return urllib2.unquote(request.url.decode('UTF-8'))
def generate_additional_graphite_image_url(self):
params = { }
params['target'] = []
params['target'].append(self.additional_graph_target)
params['target'].append('threshold(' + str(self.check.warn) + ',"Warn","yellow")')
params['target'].append('threshold(' + str(self.check.error) + ',"Error","red")')
params['from'] = '-7days'
params['width'] = '900'
params['minorGridLineColor'] = 'C0C0C0'
params['majorGridLineColor'] = 'C0C0C0'
params['bgcolor'] = '333333'
request = requests.get(self.check.GRAPHITE_URL+self.check.RENDER_PAGE,params=params)
return urllib2.unquote(request.url.decode('UTF-8'))
class Meta:
ordering = ("timestamp",)
unique_together = (("target", "timestamp"),)
答案 0 :(得分:5)
我在将项目从1.6更新到1.8时遇到了同样的问题。
问题似乎源于您的模型所具有的check
字段
它与Model.check()
方法冲突,{{1}}方法在Django's system checks期间调用,以帮助您识别模型定义中的错误。
您必须重命名该字段。