【问题标题】:Where to Disconnect() the `default_product_search_listener` in SatchmoSatchmo 中的“default_product_search_listener”在哪里断开()
【发布时间】:2011-03-26 01:34:23
【问题描述】:

我不想使用默认 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 实际上是 connect s 信号,所以他们没有正确断开连接。我可以在哪里运行我的断开连接代码,这样我才能确定 Satchmo 已经连接了它的监听器?

【问题讨论】:

    标签: python django satchmo


    【解决方案1】:

    尝试在 INSTALLED_APPS 中交换 Satchmo 和您的应用的顺序。

    【讨论】:

      【解决方案2】:

      Where To Put Django Startup Code 更普遍地回答了这个问题。

      init 中编写执行此操作的中间件,然后从 init 中引发 django.core.exceptions.MiddlewareNotUsed,django 将为所有请求删除它... p>

      见 Django documentation on writing your own middleware

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-22
        • 2023-01-03
        • 2015-12-06
        • 2011-09-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-13
        相关资源
        最近更新 更多