Friday, December 2, 2016

Django Migration Error in Heroku, but migrate correctly in heroku local

Python 3.5, Django 1.10.3, Sqlite
I have deployed a django app in heroku.It ran without errors before. One day I make some change in models.py. I first do
python manage.py collectstatic,
python manage.py makemigrations,
python manage.py migrate,
heroku local web -f Procfile.windows,
the app run correctly in local. Then I push my codes to heroku. I ran:
git push heroku master
heroku run bash
$python manage.py makemigrations
$python manage.py migrate
heroku ps:scale web=1
But server returned:

    ProgrammingError at /twitter/blog/      column twitter_article.enable_comments does not exist      LINE 1: ...article"."content", "twitter_article"."pub_date", "twitter_a.

Here is my key model:

    from django.db import models      from fluent_comments.moderation import moderate_model,comments_are_open, comments_are_moderated      from fluent_comments.models import get_comments_for_model, CommentsRelation        class Article(models.Model) :      title = models.CharField(max_length = 100)      category = models.CharField(max_length = 50, blank = True)      pub_date = models.DateTimeField(auto_now_add = True)      content = models.TextField(blank = True, null = True)      pub_date = models.DateTimeField("pub_date")      enable_comments = models.BooleanField("Enable comments", default=True)        def __str__(self) :          return self.title        class Meta:          ordering = ['-pub_date']        # Optional, give direct access to moderation info via the model:      comments = property(get_comments_for_model)      comments_are_open = property(comments_are_open)      comments_are_moderated = property(comments_are_moderated)        # Give the generic app support for moderation by django-fluent-comments:      moderate_model(Article,          publication_date_field='pub_date',          enable_comments_field='enable_comments',      )

If I drop my database and build a new database. Server won't report error. Why? I'm using sqlite.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/014a79e8-57d4-45e2-88ff-eabbefd67153%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment