0

I am trying to switch over to using MongoDB with Django, but have run into an issue. Namely, some parts of the site give a 'DatabaseError at /admin/myApp/myModel: This query is not supported by the database.' As described by the similar question posted here, this error arrises from .../admin/templates/change_list.html, and the line that throws it is line 85:

{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}

I have several models, containing a variety of CharFields, IntegerFields, BooleanFields, DateFields, URLFields, and DecimalFields. There is also a ManyToManyField:

class Trail(models.Model):
    sections = models.ManyToManyField(TrailSection)

I have had no problems with users, etc, but whenever I try to access the Trail model, I get the above error. There are no problems when I click on the TrailSection part of the /admin page, but this error appears when I click on Trail. It is ok to call

associatedTrails = Trail.objects.filter(sections=sect).order_by('-date').values('trail_id','name')

but I get the error when I later use

for t in associatedTrails:

The other question on StackOverflow documents this error as a bug that needs to be fixed, but my question is this: Why does this only happen sometimes? Why is there no problem with TrailSections or other /admin pages, but this one throws an error? Is there a good way to fix it?

Community
  • 1
  • 1
roboguy222
  • 157
  • 13

1 Answers1

0

It turns out django-norel does not support ManyToManyFields. They can be, for the most part, replaced by ListFields, which are supported in norel but not relational databases. More details can be found here.

In addition to ManyToManyFields not being supported, list_filter in admin.py can contain only one item. Maybe someone else can comment as to why, but removing using a single filter got rid of the error for all models.

Community
  • 1
  • 1
roboguy222
  • 157
  • 13