Django 1.8 RC1: ProgrammingError when creating database tables

前端 未结 4 2186
离开以前
离开以前 2020-12-16 16:03

I\'m using AbstractBaseUser for my user models in various projects. Updating to Django 1.8 RC1 works smoothly and I can run the migrate management command. However, when try

4条回答
  •  有刺的猬
    2020-12-16 16:06

    I've faced almost the same issue with Django 1.8, solved it only by running manage.py makemigrations app_name for the app with custom User model (+read below)

    e.g.:

    # some_app/models.py:
    from django.contrib.auth.models import AbstractUser
    
    
    class User(AbstractUser):
        pass
    

    AND FOR EVERY app that contained ForeignKey, OneToOneField etc references to it, e.g.:

    # another_app/models.py:
    from django.conf import settings
    from django.db import models
    
    
    class Profile(models.Model):
        user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    

    then manage.py migrate worked with no errors

    the same approach works for any app containing extensions to django.contrib models, e.g. FlatPages etc...

提交回复
热议问题