Here is a more reusable way to do this:  https://gist.github.com/3762045

On Friday, September 21, 2012 8:02:34 AM UTC-5, Garry Polley wrote:
>
> 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:
>>
>> 1) Use a middleware (
>> http://stackoverflow.com/questions/2164069/best-way-to-make-djangos-login-required-the-default
>> ) 
>>
>> 2) Use some url 'magic' to apply the decorator (
>> http://stackoverflow.com/questions/2307926/is-it-possible-to-decorate-include-in-django-urls-with-login-required
>> )
>>
>> 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? 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/CspoYIOkFXIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to