python – How do you wrap the view of a 3rd-party Django app – Education Career Blog

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?

I’ve set urls.py to capture the correct url:

url( r’^foo/bar/$’, view_wrapper, name=’my_wrapper’),

I’ve created my custom view:

from 3rd_party_app.views import view2wrap

def view_wrapper(request, *args, **kwargs):
    # Do some cool custom stuff
    return view2wrap(request, *args, **kwargs)

When I try this, I get the error “No module named 3rd_party_app.views”. Why?

,

The third party application is not in your python path.

,

Is the 3rd Party App listed in INSTALLED_APPS in your settings.py?

,

Try placing the 3rd party package folder within your project folder. 🙂

Leave a Comment