gpt4 book ai didi

django-south - 南和不能 DROP 'created_date' ;检查列/键是否存在”

转载 作者:行者123 更新时间:2023-12-04 00:43:52 24 4
gpt4 key购买 nike

我尝试添加我的模型 Markdown ,但出现错误。
我的旧models.py:

class Post(models.Model):
title = models.CharField(max_length=255)
slug = models.SlugField(max_length=255, unique=True)
excerpt = models.TextField(blank=True, help_text="A small teaser of\
your content")
content = models.TextField()
date_created = models.DateTimeField(auto_now_add=True)
is_published = models.BooleanField(default=True)
objects = models.Manager()
published_objects = PublishedManager()
tags = TaggableManager()
category = models.ForeignKey(Category)

和我的新models.py
class Post(models.Model):
title = models.CharField(max_length=255)
slug = models.SlugField(max_length=255, unique=True)
excerpt = models.TextField(blank=True, help_text="A small teaser of\
your content")
content = models.TextField()
contentmarkdown = models.TextField()
date_created = models.DateTimeField(auto_now_add=True)
is_published = models.BooleanField(default=True)
objects = models.Manager()
published_objects = PublishedManager()
tags = TaggableManager()
category = models.ForeignKey(Category)

def save(self):
self.content = markdown.markdown(self.contentmarkdown)
super(Post, self).save() # Call the "real" save() method.

当我使用南和这一行之后:python manage.py migrate blog
我收到此错误:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/management/commands/migrate.py", line 108, in handle
ignore_ghosts = ignore_ghosts,
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/migration/__init__.py", line 213, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/migration/migrators.py", line 235, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/migration/migrators.py", line 310, in migrate_many
result = self.migrate(migration, database)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/migration/migrators.py", line 133, in migrate
result = self.run(migration)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/migration/migrators.py", line 107, in run
return self.run_migration(migration)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/migration/migrators.py", line 81, in run_migration
migration_function()
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/migration/migrators.py", line 57, in <lambda>
return (lambda: direction(orm))
File "/home/ada/mainproject/blog/migrations/0004_auto__del_field_book_created_date__add_field_post_contentmarkdown__chg.py", line 12, in forwards
db.delete_column('blog_book', 'created_date')
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/db/mysql.py", line 28, in _column_rm
return func(self, table_name, column_name, *args, **opts)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/db/mysql.py", line 217, in delete_column
super(DatabaseOperations, self).delete_column(table_name, name)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/db/generic.py", line 51, in _column_rm
return func(self, table, column, *args, **opts)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/db/generic.py", line 886, in delete_column
self.execute(self.delete_column_string % params, [])
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/south/db/generic.py", line 273, in execute
cursor.execute(sql, params)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
return self.cursor.execute(query, args)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 201, in execute
self.errorhandler(self, exc, value)
File "/home/ada/virtualenv/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.DatabaseError: (1091, "Can't DROP 'created_date'; check that column/key exists")

请你告诉我为什么我会收到这个错误? 'created_date' 没有任何意义??

最佳答案

这是因为您正在尝试删除包含“created_date”列的内容,如果您查看错误,它指的是文件、行号,甚至是有问题的代码片段。

File "/home/ada/mainproject/blog/migrations/0004_auto__del_field_book_created_date__add_field_post_contentmarkdown__chg.py", line 12, in forwards db.delete_column('blog_book', 'created_date')

当您在变量“date_created”和“created_date”之间切换时,您似乎指的是错误的列名

关于django-south - 南和不能 DROP 'created_date' ;检查列/键是否存在”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14801090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com