Upgrading Django to 1.5 with Django-CMS - user model issue

爷,独闯天下 提交于 2019-12-06 01:58:42

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

For others with this question, here is my summary of what I have learned from https://github.com/divio/django-cms/issues/1798.

There are four potential options:

  1. If you need your custom user model to have a name other than User, you'll need to wait.
  2. You can call the custom user model User - though when I tried this, I got errors about clashes with related m2m fields. There are some further details on the above link which may help resolve this.
  3. Django 1.5 still lets you use user profiles. So if you are ok with using a deprecated feature, you can still use Django-CMS 2.4 and Django 1.5 with user profiles instead of a custom user model. (I misread the Django docs here and thought user profiles were not supported in Django 1.5.)
  4. You can often get away without either a user profile or a custom user model - they are best used to add data specifically for user authentication. Instead, you can use another model with a one-to-one relationship to User, and use the reverse relationship to access it.

In my case, I am going to go with #3 in the short-run and #4 in the long-run.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!