【发布时间】:2014-04-12 04:40:22
【问题描述】:
我正在尝试切换到将 MongoDB 与 Django 结合使用,但遇到了问题。即,该站点的某些部分给出了“/admin/myApp/myModel 处的数据库错误:数据库不支持此查询。”正如here 发布的类似问题所述,此错误来自.../admin/templates/change_list.html,并且抛出它的行是第 85 行:
{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
我有几个模型,包含各种 CharFields、IntegerFields、BooleanFields、DateFields、URLFields 和 DecimalFields。还有一个ManyToManyField:
class Trail(models.Model):
sections = models.ManyToManyField(TrailSection)
我没有遇到用户等问题,但是每当我尝试访问 Trail 模型时,都会收到上述错误。单击 /admin 页面的 TrailSection 部分时没有问题,但单击 Trail 时出现此错误。可以打电话
associatedTrails = Trail.objects.filter(sections=sect).order_by('-date').values('trail_id','name')
但是当我以后使用时出现错误
for t in associatedTrails:
StackOverflow 上的另一个问题将此错误记录为需要修复的错误,但我的问题是:为什么这种情况有时只会发生?为什么 TrailSections 或者其他 /admin 页面没有问题,但是这个却抛出了错误?有什么好办法解决吗?
【问题讨论】: