社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  问与答

django返回json数据问题!!

hsdtsyl • 9 年前 • 5818 次点击  

if auth_user:

auth.login(request, auth_user)

authed_user = serializers.serialize('json',
fxcn_user.objects.filter(username=user))

return HttpResponse (json.dumps(authed_user),content_type="application/json")


前端jquery得到的json数据为:

"[{\"fields\": {\"username\": \"figure\", \"first_name\": \"\", \"last_name\": \"\", \"phone\": null, \"updated_at\": \"2015-06-27T02:02:17.622Z\", \"created_at\": \"2015-06-27T02:02:17.622Z\", \"is_active\": true, \"sig_info\": null, \"office_ext\": null, \"sex\": null, \"is_superuser\": true, \"birthday\": null, \"last_login\": \"2015-07-01T08:01:31.844Z\", \"groups\": [], \"user_permissions\": [], \"password\": \"pbkdf2_sha256$20000$GCVkdJZAApJC$qZLsefU0HqKKG9M4Y9OPgI4ZWMUYAIC8tInNIOSBKRo=\", \"friends\": null, \"email\": \"f@f.com\", \"icon\": \"user_icon/default.jpeg\"}, \"model\": \"fxcn_auth.fxcn_user\", \"pk\": 1}]"


前端jquery ajax成功后的处理函数 success:function(response, status, xhr){

$('#login_form').dialog('widget').find('button').eq(1).button('enable')

alert(response);

请问: 如果从返回的json数据中得到用户名,邮箱等信息??

我尝试了alert(response.username)提示undefined; }

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/1139
 
5818 次点击  
文章 [ 2 ]  |  最新文章 9 年前