Where to Disconnect()Satchm中的“default_product_search_listener”

2024-05-23 02:02:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我不想使用默认的Satchmo搜索侦听器。我创建了自己的搜索侦听器。在

断开默认搜索侦听器的最佳位置在哪里?在

# This is what I need to do...
from satchmo_store.shop.listeners import default_product_search_listener
application_search.disconnect(default_product_search_listener, sender=Product)

我试图在我的应用程序的__init__.py和我的应用程序的models.py中执行,但这两个程序似乎都是在Satchmo发出信号之前运行的,所以它们不能正确地断开连接。我可以在哪里运行断开连接的代码,这样就可以确保Satchmo已经连接了它的侦听器?在


Tags: tofrompy应用程序defaultsearchisproduct
2条回答

这个问题的答案通常是Where To Put Django Startup Code。在

Write middleware that does this in init and afterwards raise django.core.exceptions.MiddlewareNotUsed from the init, django will remove it for all requests...

请参阅Djangodocumentation on writing your own middleware。在

尝试在已安装的应用程序中交换Satchmo和你的应用程序的顺序。在

相关问题 更多 >

    热门问题