Where to Disconnect() the `default_product_search_listener` in Satchmo

半腔热情 提交于 2020-01-07 04:21:08

问题


I don't want to use the Default Satchmo search listener. I've created my own search listener instead.

Where is the best place to disconnect the default search listener?

# 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)

I was trying to do it in my app's __init__.py and the my app's models.py, but both of those seemed to run before Satchmo actually connects the Signal, so they don't properly disconnect things. Where can I run my disconnect code so that I can be assured Satchmo has already connected its listener?


回答1:


Try swapping the order of Satchmo and your app in INSTALLED_APPS.




回答2:


The answer to this question is more generally answered by 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...

See the Django documentation on writing your own middleware.



来源:https://stackoverflow.com/questions/5439769/where-to-disconnect-the-default-product-search-listener-in-satchmo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!