gpt4 book ai didi

python - Django 类覆盖失败系统检查

转载 作者:太空狗 更新时间:2023-10-30 01:07:52 26 4
gpt4 key购买 nike

我正在尝试在我的开发环境中从 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"),)

最佳答案

我在将项目从 1.6 更新到 1.8 时遇到了同样的问题。

问题似乎源于您的模型的 check 字段。
它与在 Django's system checks 期间调用的 Model.check() 方法冲突帮助您识别模型定义中的错误。

您必须重命名该字段。

关于python - Django 类覆盖失败系统检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27607988/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com