我遇到了一个奇怪的问题......我有以下代码在我的本地开发中运行良好,但是当我在项目开发服务器中使用相同的代码时,我得到一个 KeyError: 'firstname' 要么我错过了一些非常愚蠢的东西在这里,或者我不知道的东西。
def register(self,request, **kwargs):
try:
data = self.deserialize(request, request.raw_post_data, format=request.META.get('CONTENT_TYPE', 'application/json'))
print data
print " reached register"
email = data['email']
password = data['password']
firstname = data['firstName']
lastname = data['lastName']
newdata = {'email' : email , 'password1': password , 'password2':password, 'firstname':firstname , 'lastname':lastname }
日志输出如下:
[Wed Jul 31 21:42:24 2013] [error] {u'lastName': u'Adams', u'password': u'pass', u'email': u'samad@g.com', u'firstName': u'Sam'}
[Wed Jul 31 21:42:24 2013] [error] reached register
[Wed Jul 31 21:42:24 2013] [error] ERROR:root:'firstname'
[Wed Jul 31 21:42:24 2013] [error] Traceback (most recent call last):
[Wed Jul 31 21:42:24 2013] [error] File "/home/ubuntu/djangoEC/userdetails/api.py", line 102, in register
[Wed Jul 31 21:42:24 2013] [error] firstname = data['firstName']
[Wed Jul 31 21:42:24 2013] [error] KeyError: 'firstname'
呸,有什么想法吗?