rest_framework-2-權限
阿新 • • 發佈:2018-04-30
image svi .py name img class close eve div
權限
1.models.py
from django.db import models class UserInfo(models.Model): user_type_choices = ( (1,‘普通用戶‘), (2,‘VIP‘), (3,‘SVIP‘), ) user_type = models.IntegerField(choices=user_type_choices) # username = models.CharField(max_length=32) username = models.CharField(max_length=32,unique=True) passwordmodels.py= models.CharField(max_length=64) class UserToken(models.Model): user = models.OneToOneField(to=‘UserInfo‘) token = models.CharField(max_length=64)
2.views.py:
假設訂單相關業務(只有SVIP用戶有權限)
假設用戶信息相關業務(只有普通用戶、VIP有權限)
2.
3.
4.
5.
rest_framework-2-權限