Django DRF 3.9.2 breaks my ViewSet actions2019 Community Moderator Electionaggregate(Max('id')) returns exception 'str' object has no attribute 'email'django test RequestFactory cannot get route parameter to workExtending django User django-rest_framework gives me KeyErrorConnectionRefusedError in dJango rest api while registration processImage with a chinese filename returns UnicodeEncodeErrorDjango - get_queryset() missing 1 required positional argument: 'request'Return NoneType on queryset django REST frameworkDjango REST: Uploading and serializing multiple imagesDjango rest framework: catch ValidationError from external packageDjango Rest Framework: serializer response error
It's a yearly task, alright
Could the Saturn V actually have launched astronauts around Venus?
Co-worker team leader wants to inject his friend's awful software into our development. What should I say to our common boss?
Why using two cd commands in bash script does not execute the second command
SQL Server Primary Login Restrictions
RegionDifference for Cylinder and Cuboid
Old race car problem/puzzle
Check this translation of Amores 1.3.26
What is a good source for large tables on the properties of water?
Meaning of "SEVERA INDEOVI VAS" from 3rd Century slab
Happy pi day, everyone!
Why is "das Weib" grammatically neuter?
Welcoming 2019 Pi day: How to draw the letter π?
Bash: What does "masking return values" mean?
Professor being mistaken for a grad student
Be in awe of my brilliance!
Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?
Pinhole Camera with Instant Film
Identifying the interval from A♭ to D♯
My adviser wants to be the first author
Replacing Windows 7 security updates with anti-virus?
How could a scammer know the apps on my phone / iTunes account?
Informing my boss about remarks from a nasty colleague
How to generate globally unique ids for different tables of the same database?
Django DRF 3.9.2 breaks my ViewSet actions
2019 Community Moderator Electionaggregate(Max('id')) returns exception 'str' object has no attribute 'email'django test RequestFactory cannot get route parameter to workExtending django User django-rest_framework gives me KeyErrorConnectionRefusedError in dJango rest api while registration processImage with a chinese filename returns UnicodeEncodeErrorDjango - get_queryset() missing 1 required positional argument: 'request'Return NoneType on queryset django REST frameworkDjango REST: Uploading and serializing multiple imagesDjango rest framework: catch ValidationError from external packageDjango Rest Framework: serializer response error
I've updated DRF to 3.9.2 and now my actions break with the very weird:
...
File "/usr/local/lib/python3.5/site-packages/rest_framework/views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.5/site-packages/rest_framework/views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
TypeError: 'str' object is not callable
Upon closer inspection, it seems the handler method is simply defined as 'Name' and so trying to call a string results in a TypeError:
# Get the appropriate handler method
if request.method.lower() in self.http_method_names:
# request.method.lower() is 'post' so self.post returns 'Name'
handler = getattr(self, request.method.lower(),
self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
This is my viewset:
class ValidateViewSet(viewsets.ViewSet):
@action(methods=('post',), detail=False, permission_classes=())
def name(self, request):
response, code = self.validate(request.data, NameSerializer)
return Response(response, code)
and this is how I register it:
router = SimpleRouter()
router.register(
'customer/register/validate',
contact_registration.ValidateViewSet,
'customer-register-validate',
)
This works perfectly fine in 3.8.2 but I'm not sure exactly what changed in 3.9.0 onwards that it's no longer good.
EDIT: Looks like renaming the action from name to something else fixes it, is name reserved somehow?
EDIT: After going through the 3.9.0 PRs, I suspect this is the culprit as it introduces a class variable called name. I think that should be at least documented if not fixed.
EDIT: Issue raised, seems like the best option is to document these more explicitly.
python django-rest-framework
add a comment |
I've updated DRF to 3.9.2 and now my actions break with the very weird:
...
File "/usr/local/lib/python3.5/site-packages/rest_framework/views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.5/site-packages/rest_framework/views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
TypeError: 'str' object is not callable
Upon closer inspection, it seems the handler method is simply defined as 'Name' and so trying to call a string results in a TypeError:
# Get the appropriate handler method
if request.method.lower() in self.http_method_names:
# request.method.lower() is 'post' so self.post returns 'Name'
handler = getattr(self, request.method.lower(),
self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
This is my viewset:
class ValidateViewSet(viewsets.ViewSet):
@action(methods=('post',), detail=False, permission_classes=())
def name(self, request):
response, code = self.validate(request.data, NameSerializer)
return Response(response, code)
and this is how I register it:
router = SimpleRouter()
router.register(
'customer/register/validate',
contact_registration.ValidateViewSet,
'customer-register-validate',
)
This works perfectly fine in 3.8.2 but I'm not sure exactly what changed in 3.9.0 onwards that it's no longer good.
EDIT: Looks like renaming the action from name to something else fixes it, is name reserved somehow?
EDIT: After going through the 3.9.0 PRs, I suspect this is the culprit as it introduces a class variable called name. I think that should be at least documented if not fixed.
EDIT: Issue raised, seems like the best option is to document these more explicitly.
python django-rest-framework
add a comment |
I've updated DRF to 3.9.2 and now my actions break with the very weird:
...
File "/usr/local/lib/python3.5/site-packages/rest_framework/views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.5/site-packages/rest_framework/views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
TypeError: 'str' object is not callable
Upon closer inspection, it seems the handler method is simply defined as 'Name' and so trying to call a string results in a TypeError:
# Get the appropriate handler method
if request.method.lower() in self.http_method_names:
# request.method.lower() is 'post' so self.post returns 'Name'
handler = getattr(self, request.method.lower(),
self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
This is my viewset:
class ValidateViewSet(viewsets.ViewSet):
@action(methods=('post',), detail=False, permission_classes=())
def name(self, request):
response, code = self.validate(request.data, NameSerializer)
return Response(response, code)
and this is how I register it:
router = SimpleRouter()
router.register(
'customer/register/validate',
contact_registration.ValidateViewSet,
'customer-register-validate',
)
This works perfectly fine in 3.8.2 but I'm not sure exactly what changed in 3.9.0 onwards that it's no longer good.
EDIT: Looks like renaming the action from name to something else fixes it, is name reserved somehow?
EDIT: After going through the 3.9.0 PRs, I suspect this is the culprit as it introduces a class variable called name. I think that should be at least documented if not fixed.
EDIT: Issue raised, seems like the best option is to document these more explicitly.
python django-rest-framework
I've updated DRF to 3.9.2 and now my actions break with the very weird:
...
File "/usr/local/lib/python3.5/site-packages/rest_framework/views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.5/site-packages/rest_framework/views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
TypeError: 'str' object is not callable
Upon closer inspection, it seems the handler method is simply defined as 'Name' and so trying to call a string results in a TypeError:
# Get the appropriate handler method
if request.method.lower() in self.http_method_names:
# request.method.lower() is 'post' so self.post returns 'Name'
handler = getattr(self, request.method.lower(),
self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
This is my viewset:
class ValidateViewSet(viewsets.ViewSet):
@action(methods=('post',), detail=False, permission_classes=())
def name(self, request):
response, code = self.validate(request.data, NameSerializer)
return Response(response, code)
and this is how I register it:
router = SimpleRouter()
router.register(
'customer/register/validate',
contact_registration.ValidateViewSet,
'customer-register-validate',
)
This works perfectly fine in 3.8.2 but I'm not sure exactly what changed in 3.9.0 onwards that it's no longer good.
EDIT: Looks like renaming the action from name to something else fixes it, is name reserved somehow?
EDIT: After going through the 3.9.0 PRs, I suspect this is the culprit as it introduces a class variable called name. I think that should be at least documented if not fixed.
EDIT: Issue raised, seems like the best option is to document these more explicitly.
python django-rest-framework
python django-rest-framework
edited Mar 7 at 10:43
Nobilis
asked Mar 6 at 13:41
NobilisNobilis
5,3252149
5,3252149
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55024513%2fdjango-drf-3-9-2-breaks-my-viewset-actions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55024513%2fdjango-drf-3-9-2-breaks-my-viewset-actions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown