开发者

django-non rel and dbindexer ordering property

I am working on a test project using django-nonrel.

After enabling the admin interface and adding some entities to the database, I added a search_field to the ModelAdm开发者_C百科in class. As I tried to search I got the following error:

DatabaseError: Lookup type 'icontains' isn't supported

In order to fix this, I added an index like this:

from models import Empresa
from dbindexer.api import register_index

register_index(Empresa, {'nombre': 'icontains'})

But now I am getting the following error:

First ordering property must be the same as inequality filter property, if specified for this query; received key, expected idxf_nombre_l_icontains

Am I trying to do something that is not supported by django-nonrel and dbindex yet?

Thanks in advance for any help


I have the same problem (on another case), know the cause of it, but currently have no solution.

It is because of GAE's database limitation in which if a query contain an inequality comparison, that is ' < , > , >= ' or something like that, any ordering of any member of the entities (other than the member that use the inequality comparison) must be preceded by an ordering of the member with inequality comparison first.

If we are directly using GAE's database, this limitation can easily be overcome by first set the order by the member that use the inequality first, than sort with whatever you want to sort.

Unfortunately, the django-nonrel and djangoappengine's database wrapper seems to be unable to do that (I've tried the order by first technique using django model, still error, maybe it's just me), not to mention the use of dbindexer as the wrapper of djangoappengine.db which itself is a wrapper of GAE's database......

Bottomline, debugging can be a hell for this mess. You may want to use GAE datastore directly just for this case, or wait for djangoappengine team to come up with better alternative.


I kind of fixed it by changing the ordering property in the ModelAdmin subclass:

class EmpresaAdmin(admin.ModelAdmin):
    search_fields = ('nombre',)
    #order by the atribute autogenerated by dbindex
    ordering = ('idxf_nombre_l_icontains',)

Does anyone know a better way to fix this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜