django-non rel 和 dbindexer 排序属性

发布于 2024-11-23 19:56:39 字数 555 浏览 3 评论 0原文

我正在使用 django-nonrel 进行一个测试项目。

启用管理界面并向数据库添加一些实体后,我向 ModelAdmin 类添加了一个 search_field 。当我尝试搜索时,出现以下错误:

数据库错误:不支持查找类型“icontains”

为了解决此问题,我添加了如下索引:

from models import Empresa
from dbindexer.api import register_index

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

但现在我收到以下错误:

如果为此查询指定了第一个排序属性,则必须与不等式过滤器属性相同;收到密钥,预期为 idxf_nombre_l_icontains

我是否正在尝试执行 django-nonrel 和 dbindex 尚不支持的操作?

预先感谢您的任何帮助

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 ModelAdmin 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

脸赞 2024-11-30 19:56:39

我有同样的问题(在另一个案例中),知道其原因,但目前没有解决方案。

这是因为GAE的数据库限制,如果查询包含不等比较,即 ' < > ,> 、>= ' 或类似的内容,实体的任何成员(使用不等式比较的成员除外)的任何排序必须先于首先进行不等式比较的成员的排序。

如果我们直接使用GAE的数据库,这个限制可以很容易地克服,方法是首先由首先使用不等式的成员设置顺序,而不是按照你想要排序的任何内容进行排序。

不幸的是,django-nonrel和djangoappengine的数据库包装器似乎无法做到这一点(我已经尝试使用django模型的第一种技术的顺序,仍然错误,也许只是我),更不用说使用dbindexer作为包装器djangoappengine.db 本身就是 GAE 数据库的包装器……

最重要的是,调试对于这个混乱来说可能是一个地狱。对于这种情况,您可能想直接使用 GAE 数据存储,或者等待 djangoappengine 团队提出更好的替代方案。

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.

不爱素颜 2024-11-30 19:56:39

我通过更改 ModelAdmin 子类中的排序属性来修复它:

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

有人知道更好的方法来修复这个问题吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文