Allow None
as redirect_field_name value for user_passes_test
and login_required
#1600
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to the Django documentation, the
redirect_field_name
argument touser_passes_test
acceptsNone
as a value as well as a string, but Django Stubs currently only recognises strings as acceptable values. Specifically, passing aNone
indicates that the redirect field should be omitted.The documentation does not explicitly state whether
redirect_field_name
oflogin_required
allows or does not allowNone
values, but my own usage indicates that it does and it behaves in the same way.I haven't attempted to make this change globally for all instances of
redirect_field_name
since I'm not familiar with all their usages, but note that some cases already allowNone
s while others that still won't.pytest
runs with 31 failures (344 passes), however this is the same as I get onmaster
stubtest.sh
There is not an open issue related to this as far as I am aware - I noticed the problem and since it was a simple solution I went straight to fixing.