Re: Decorator function argument woes

2018-05-07 Thread Peter of the Norse
Yes, but that’s because all of the arguments are optional. That way you can do: @login_required def my_view(request): … @login_required(login_url=“/login/“) def other_view(request): … - Peter of the Norse > On Apr 30, 2018, at 12:24 AM, Mike Dewhirst wrote: > >> On 30/04/2018 3:35 PM

Solved Re: Decorator function argument woes

2018-04-30 Thread Mike Dewhirst
Stephen Not really solved except I gave up on decorating when I finally "got" it. Thanks again. 1. made two new sub-views for the two scenarios and decorated one of them with login_required 2. factored out all the commonalities into a new undecorated view with the same name as used in urls

Re: Decorator function argument woes

2018-04-29 Thread Mike Dewhirst
On 30/04/2018 4:30 PM, Stephen J. Butler wrote: Yes. I don't see it in the documentation for login_required, but I believe it's so that you can do something like this in your urls.py: urlpatterns = [     url(r'^example$', login_required(views.example)), ] That might be an older way of using th

Re: Decorator function argument woes

2018-04-29 Thread Stephen J. Butler
Yes. I don't see it in the documentation for login_required, but I believe it's so that you can do something like this in your urls.py: urlpatterns = [ url(r'^example$', login_required(views.example)), ] That might be an older way of using the decorator? IDK for sure. But you can see from the

Re: Decorator function argument woes

2018-04-29 Thread Mike Dewhirst
On 30/04/2018 3:35 PM, Stephen J. Butler wrote: @login_required doesn't take a test function. You need to use @user_passes_test directly. Thank you Stephen. I thought I'd start another thread to ask about my use case of being able to require login or not depending on whether the content neede

Re: Decorator function argument woes

2018-04-29 Thread Stephen J. Butler
@login_required doesn't take a test function. You need to use @user_passes_test directly. On Mon, Apr 30, 2018 at 12:26 AM, Mike Dewhirst wrote: > I'm pretty sure this is a not-understanding-python problem rather than a > Django problem but here goes ... > > In a (FBV) view I'm trying to pass a

Decorator function argument woes

2018-04-29 Thread Mike Dewhirst
I'm pretty sure this is a not-understanding-python problem rather than a Django problem but here goes ... In a (FBV) view I'm trying to pass a function in to the login_required decorator. My function is called 'is_login_needed' and I want the login_required