如何包装第三方Django应用程序的视图 [英] How do you wrap the view of a 3rd-party Django app
本文介绍了如何包装第三方Django应用程序的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何包装第三方应用程序的视图(让我们调用视图来封装view2wrap和应用程序3rd_party_app),以便您可以在应用程序执行之前做一些自定义的事情?
How do you wrap the view of a 3rd-party app (let's call the view to wrap "view2wrap" and the app "3rd_party_app") so you can do some custom things before the app does its thing?
我设置了 urls.py 来捕获正确的URL:
I've set urls.py to capture the correct url:
url(r'^ foo / bar / $',view_wrapper,name ='my_wrapper'),
url( r'^foo/bar/$', view_wrapper, name='my_wrapper'),
我创建了我的自定义视图:
from 3rd_party_app.views import view2wrap
def view_wrapper(request, *args, **kwargs):
# Do some cool custom stuff
return view2wrap(request, *args, **kwargs)
当我尝试这个,我得到错误没有模块名为3_party_app.views。为什么?
When I try this, I get the error "No module named 3rd_party_app.views". Why?
推荐答案
第三方应用程序不在您的python路径。
The third party application is not in your python path.
这篇关于如何包装第三方Django应用程序的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文