staff_member_required() takes at least 1 argument (1 given)
--
Ticket URL: <https://code.djangoproject.com/ticket/24294>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> When a valid argument is given to staff_member_required decorator, it
> raises this confusing error:
>
> staff_member_required() takes at least 1 argument (1 given)
New description:
When a valid argument is given to staff_member_required decorator, it
raises this confusing error:
staff_member_required() takes at least 1 argument (1 given)
e.g.:
@staff_member_required(redirect_field_name='test')
def v1(request):
return HttpResponse("hi")
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:1>
Old description:
> When a valid argument is given to staff_member_required decorator, it
> raises this confusing error:
>
> staff_member_required() takes at least 1 argument (1 given)
>
> e.g.:
> @staff_member_required(redirect_field_name='test')
> def v1(request):
> return HttpResponse("hi")
New description:
When a valid argument is given to staff_member_required decorator, it
raises this confusing error:
staff_member_required() takes at least 1 argument (1 given)
e.g.::
@staff_member_required(redirect_field_name='test')
def v1(request):
return HttpResponse("hi")
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:2>
Old description:
> When a valid argument is given to staff_member_required decorator, it
> raises this confusing error:
>
> staff_member_required() takes at least 1 argument (1 given)
>
> e.g.::
> @staff_member_required(redirect_field_name='test')
> def v1(request):
> return HttpResponse("hi")
New description:
When a valid argument is given to staff_member_required decorator, it
raises this confusing error:
staff_member_required() takes at least 1 argument (1 given)
{{{
@staff_member_required(redirect_field_name='test')
def v1(request):
return HttpResponse("hi")
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:3>
* stage: Unreviewed => Accepted
Comment:
The issue here is simply that `staff_member_required` is not written to be
automatically either a decorator or decorator-factory: it always requires
a `view_func` as its first positional argument. So it simply doesn't
support the way you are trying to use it; if you want to provide extra
options to it, you can no longer use it with `@` syntax.
If we are documenting it and making it public API, it should probably work
like `login_required`, which would make your code work.
--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:4>
Comment (by collinanderson):
#24253 is about making staff_member_required a public api.
--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:5>
Comment (by johngian):
I pushed a branch with a fix for that ticket here:
https://github.com/johngian/django/tree/ticket_24294
--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:6>
* has_patch: 0 => 1
* needs_tests: 0 => 1
Comment:
Can you point to the existing pull request?
This will also require a test.
--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:7>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"08572e8d125da204fab230be5d1fdcc5d8d22256"]:
{{{
#!CommitTicketReference repository=""
revision="08572e8d125da204fab230be5d1fdcc5d8d22256"
Fixed #24294 -- Allowed staff_member_required decorator to handle args.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:8>