django 1.5 extend the default User model or substitute it

后端 未结 2 1304
谎友^
谎友^ 2021-01-14 09:16

Env: Django 1.5.1 + Django CMS 2.4.1 + Zinnia latest + my custom apps + custom Django CMS plugin

Basically I can extend the default Django (1.5.X) User model like D

2条回答
  •  庸人自扰
    2021-01-14 09:31

    There is very simple solution. Just need to register your custom user before importing CMSPlugin. Example:

    from django.db import models
    from django.contrib.auth import models as auth_models
    from django.contrib.auth.models import AbstractUser
    
    class User(AbstractUser):
      telephone = models.CharField(max_length=100)
      email = models.CharField(max_length=100)
    
    auth_models.User = User
    
    from cms.models import CMSPlugin
    

提交回复
热议问题