1.个人中心:获取用户身份数据
1.apps/users/adminx.py中对UserProfile的序列化类进行修改为:
class UserProfileModelSerializer(serializers.ModelSerializer): class Meta: model = UserProfile fields=['nickName','avatarUrl','jifen','yongjin','fensi_num']
2.apps/users/views.py中新建获取用户信息类GetUserInfo:
class GetUserInfo(APIView): """获取用户信息""" renderer_classes = [JSONRenderer] # 渲染器 def get(self,request): token=request.GET.get('token') user=UserProfile.objects.filter(token=token).first() re=UserProfileModelSerializer(user) return Response(re.data)
3.在apps/users/urls.py中添加路由:
from django.urls import path from .views import LoginView,GetUserInfo urlpatterns = [ path('login/',LoginView.as_view()), path('getuserinfo/',GetUserInfo.as_view()) ]
2.个人中心:获取用户发布的广告和店铺及图片
1.在apps/ad/views.py中