添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I deleted a model field ( created_date ) on my local django models.py .

Some of the migrations and / or pulls from Github to pythonanywhere must have failed, and I got "No such column" error. I then dropped the table on sqlite, deleted all migrations files and got "table does not exist".

I managed to recreate all migrations, run makemigrations and migrate until everything is up to date. But I still get the "no such column" error.

pragma table_info('suquiwrites_entry');                                                                                                     
cid         name        type        notnull     dflt_value  pk        
----------  ----------  ----------  ----------  ----------  ----------
0           id          integer     1                       1         
1           title       varchar(20  1                       0         
2           text        text        1                       0         
3           published_  datetime    0                       0         
4           author_id   integer     1                       0         
sqlite>

models.py:

from django.db import models
from django.conf import settings
from datetime import datetime
class Entry(models.Model):
    author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    title = models.CharField(max_length=200)
    text = models.TextField()
    published_date = models.DateTimeField(blank=True, null=True)
    def publish(self, value):
        self.published_date = datetime.strptime(value, "%d-%m-%Y").date()
        self.save()
    def __str__(self):
        return self.title

Error code : Exception Value: no such column: suquiwrites_entry.created_date

What I did in the end was to manually recreate all migration files in the bash console, using touch to create and nano to copy paste the content from my local files into the pythonanywhere files. Then I rerun migrate and even though I got the warning Entry has no field named 'created_date', the page is now deployed.

However, now when I run any other command, it's asking me to rerun migrations and I get the same error.

Sorry, we have had to rate-limit your feedback sending.
Please try again in a few moments... Thanks for the feedback! Our tireless devs will get back to you soon.