循环makemigrations / migrate问题:不应用迁移

时间:2015-04-12 13:50:08

标签: python django postgresql heroku

我在部署到Heroku的Django 1.8应用程序上有这个模型。当我跑“makemigrations'我明白了:

Migrations for 'account':
  0002_auto_20150412_1337.py:
    - Alter field email on emailaddress
Migrations for 'socialaccount':
  0002_auto_20150412_1337.py:
    - Alter field provider on socialaccount
    - Alter field provider on socialapp

但是当我跑步'迁移'我明白了:

Operations to perform:
  Synchronize unmigrated apps: messages, allauth, staticfiles, facebook
  Apply all migrations: accounts, sites, auth, socialaccount, account, admin, contenttypes, sessions
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

我在为1.6构建类似的应用程序之前遇到过这种情况,然后我通过伪造第一次迁移来解决它。这次似乎不会有效。

from django.db import models
from django.contrib.auth.models import User
from allauth.account.signals import user_signed_up
from django.dispatch import receiver
from appname import settings

class UserProfile(models.Model):
    user = models.OneToOneField(User, related_name='profile')
    age = models.IntegerField(null = True)
    location = models.CharField(max_length = 50, null = True, default ="")
    display_name = models.CharField(max_length = 50, null = True, default ="")
    updated_profile = models.BooleanField(default = False)
    rating_access = models.BooleanField(default = False)
    rating = models.IntegerField(default = 0)
    seen_introduction = models.BooleanField(default = False)

    def __unicode__(self):
        return "%s profile. Age: %s, Location: %s" % (self.user.username, self.age, self.location)

@receiver(user_signed_up)
def new_user_signup(sender, **kwargs):
    p = UserProfile(user = kwargs['user'])
    p.save()

0 个答案:

没有答案
相关问题