小编A.J*_*JRJ的帖子

Django drf simple-jwt authentication"detail": "没有找到具有给定凭据的活动帐户"

我正在使用带有自定义用户的 django-rest_framework_simple-jwt 实现用户身份验证,我的 models.py:

class UserManager(BaseUserManager):
    def create_user(self, email, username, password, alias=None):
        user = self.model(
        email = self.normalize_email(email),
                username = username,)
        user.set_password(password)
        user.save()
        return user
   def create_superuser(self, email, username, password):
       self.create_user(email, username, password)
       user.is_staff()
       user.is_superuser = True
       user.save()
       return user

class User(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(null=False, unique=True)
    username = models.CharField(max_length=25, unique=True)
    is_active = models.BooleanField(default=True)
    is_staff = models.BooleanField(default=False)

    objects = UserManager()
    USERNAME_FIELD = "email"
    REQUIRED_FIELDS = ["username",]
Run Code Online (Sandbox Code Playgroud)

所以我正在实现restframework simple-jwt身份验证,我的设置.py如下:

REST_FRAMEWORK={
  'DEFAULT_AUTHENTICATION_CLASSES': [
      'rest_framework_simplejwt.authentication.JWTAuthentication',
   ]}
Run Code Online (Sandbox Code Playgroud)

我的 urls.py:

urlpatterns = [
       url(r'^api/token/$', TokenObtainPairView.as_view(), …
Run Code Online (Sandbox Code Playgroud)

django django-rest-framework django-rest-framework-simplejwt

10
推荐指数
2
解决办法
7232
查看次数

如何在GCP中的DeploymentManager在VM实例创建中包括防火墙

我的yaml模板如下,我想添加防火墙属性以允许http流量:

resources:

    - name: deployed-vm2222
      type: compute.v1.instance
      properties:
        zone: us-central1-f           
        machineType: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/machineTypes/f1-micro
        disks:
        - deviceName: boot
          type: PERSISTENT
          boot: true
          autoDelete: true
Run Code Online (Sandbox Code Playgroud)

google-cloud-platform google-deployment-manager

3
推荐指数
3
解决办法
5007
查看次数