微信抢票并发过程中有关数据有效性的验证
I am not very sure what to do at the beginning to be honest.This project may be the most complex one I have seen. But I am sure that at least I have to have a login website. So I choose to finish this interface at first.
In the instruction, we are asked to return a code 0 when successfully authenticated, and code 1 when some error occurred. I though I have to write something like "return {''code'':0}" at the very start. But I am wrong. This project doesn''t work in that way. In this project, all api views should inherit from the "APIView". "return code 0 or 1" is written by origin author in api_wrapper. If we want to return a code 0 in our "get" or "post" method, we just need to let the function terminate normally. If we need a code -1, just raise a error.
By the way, the auth method in django 1.9.5 doesn''t need param request. So use "auth.authenticate(username=''username'', password=''password'')" instead of "auth.authenticate(self.request, username=''username'', password=''password'')" .
相关评论