Re: Decorate 3rd party app's views

42 views
Skip to first unread message

Garry Polley

unread,
Sep 21, 2012, 9:02:34 AM9/21/12
to django...@googlegroups.com
Here is an example of yet another way to do it http://pastebin.com/JUnk4epK. I like this way because it does not introduce too much extra code into the codebase.   

I'd really like if I could just add an include function called decorated_include and pass the decorator and the urls to include to that function.  It would do the same thing this bit of code is doing. 

On Thursday, September 20, 2012 11:22:01 AM UTC-5, Garry Polley wrote:
Currently I am having to choose between two ways to decorate 3rd party apps views:



What I would like to do is this:

url(r'^authurls', login_required(include('someapp.urls'), login_url='path/to/login'))


So 2 questions:

1)  What does everyone else do to accomplish this?

2) What should 3rd party apps (or Django) do to allow you to decorate their views, if they should at all? 

Garry Polley

unread,
Sep 21, 2012, 11:06:52 AM9/21/12
to django...@googlegroups.com
Here is a more reusable way to do this:  https://gist.github.com/3762045
Reply all
Reply to author
Forward
0 new messages