0

我正在使用 Python 3.4 Django 1.7。我的项目包括 3 个具有相似模型的应用程序,例如:

我有一个 ElectricityBill 应用程序:

Account, Meter, Invoice models.

我还有一个 NaturalGasBill 应用程序:

Account, Meter, Invoice models.

当我注册我的自动完成时,(两个应用程序相同),第二个总是会替换第一个..例如..当我转到 localhost/autocomplete 我得到这个:

InvoiceAutocomplete     /autocomplete/InvoiceAutocomplete/
AccountAutocomplete     /autocomplete/AccountAutocomplete/
MeterAutocomplete   /autocomplete/MeterAutocomplete/

显然,这些 url 并没有什么独特之处来指示 url 应该适用于哪个应用程序。

有人对此有解决方案吗?

4

1 回答 1

0

在文档中找到了这个:

# Extra **kwargs are used as class properties in the subclass.
autocomplete_light.register(SomeModel,
# SomeModel is already registered, re-register with custom name
name='AutocompleSomeModelNew',
# Filter the queryset
choices=SomeModel.objects.filter(new=True))

文档链接在这里:https ://django-autocomplete-light.readthedocs.org/en/docs_rewrite/cookbook.html

使用客户名称注册自动完成正是我想要的。不幸的是,这在文档中很难找到。

于 2015-12-08T15:17:55.390 回答