我最近通过我们的PhantomJS测试套件运行了我们的网站,并遇到了JavaScript错误,我手动无法在浏览器中重现这些错误.这些错误可在Google maps api中找到,Capybara返回的文本如下:
TypeError: Unable to delete property.
TypeError: Unable to delete property.
at :215
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:19
at :214
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:21
at :176
at :31
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:26 in Yf
at :178
Run Code Online (Sandbox Code Playgroud)
这是Capybara,PhantomJS或Google maps API的已知错误吗?问题可能是由PhantomJS中的用户代理字符串引起的吗?
使用多表继承,我有两个模型:
class Bird(models.Model):
color = models.CharField()
class Bluebird(Bird):
...
Run Code Online (Sandbox Code Playgroud)
使用这些模型,我可以做到这一点:
birds = Bird.objects.all()
for bird in birds:
print bird.color
Run Code Online (Sandbox Code Playgroud)
这非常简单,但我不喜欢在某些情况下允许人们定义任意颜色值。例如,我想阻止用户创建Bluebird颜色字段设置为任何东西的对象,"blue"或者,在更罕见的情况下,"grey"或者"brown"。换句话说,我想在模型内的choices继承color字段上设置kwarg Bluebird。从粗略的互联网搜索来看,Django 目前似乎不允许模型子类覆盖父类的字段。
如何color在子类中定义可接受的选择的同时保留对父类中的字段的访问权限?
编辑:这个问题的重点是 Django < 1.8。在 1.8 中,添加了为字段的choiceskwarg传递可调用的功能,虽然这很好,但我正在处理尚未升级的系统,升级目前不是一种选择。
django inheritance overriding django-models multi-table-inheritance