APIView call initial method before checking the request method #8706
              
                Unanswered
              
          
                  
                    
                      zankoAn
                    
                  
                
                  asked this question in
                Potential Issue
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
I have view inheritance from APIView and I limit the request method to just accept the POST method, but In a situation where I generate the Authorization header with the wrong username/password and send it with the GET method, the view raises an exception: 
{"detail": "Invalid username/password."}but I send it with the GET method, not POST!! why still work?I checked the source code of APIView and see in the dispatch method first in the
try/exceptblock call the initial method and then the request method is checked, but this initial method raises an exception because therequest.userwas not found and this exception was ignored the request method checking and return the response{"detail": "Invalid username/password."}Is this a bug or just me thinking it's a bug!!?
Beta Was this translation helpful? Give feedback.
All reactions