【发布时间】:2021-01-15 04:24:25
【问题描述】:
请帮助我从 python manage.py makemigrations 中得到这个错误
“post”的迁移:post/migrations/0022_auto_20200929_1749.py - 从帖子中删除字段类别 - 从 post Traceback 中删除字段标签(最近一次调用最后一次):文件“manage.py”,第 22 行,在 main() 文件“manage.py”,第 18 行,在 main execute_from_command_line(sys.argv) 文件 "/usr/lib/python3.8/site-packages/django/core/management/init.py", 第 381 行,在 execute_from_command_line utility.execute() 文件 "/usr/lib/python3.8/site-packages/django/core/management/init.py", 第 375 行,执行中 self.fetch_command(subcommand).run_from_argv(self.argv) 文件“/usr/lib/python3.8/site-packages/django/core/management/base.py”, 第 336 行,在 run_from_argv connections.close_all() 文件“/usr/lib/python3.8/site-packages/django/db/utils.py”,第 224 行,在 关闭所有 connection.close() 文件“/usr/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py”, 第 248 行,关闭 如果不是 self.is_in_memory_db():文件“/usr/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py”, 第 367 行,在 is_in_memory_db 中 返回 self.creation.is_in_memory_db(self.settings_dict['NAME']) 文件 “/usr/lib/python3.8/site-packages/django/db/backends/sqlite3/creation.py”, 第 12 行,在 is_in_memory_db 中 在 database_name 中返回 database_name == ':memory:' 或 'mode=memory' TypeError: 'PosixPath' 类型的参数不是 iterabl
模型.py 从 django.db 导入模型
> # Create your models here. from django.db import models from django.utils import timezone
>
>
> class Post(models.Model):
> author = models.ForeignKey('auth.User', on_delete=models.CASCADE ,null=True)
> title = models.CharField(max_length=200,null=True)
> description=models.TextField(default='a')
> text = models.TextField(null=True)
> Img = models.ImageField(upload_to='images/',null =True)
> UserImg= models.ImageField(upload_to='images/user/',null =True)
>
> created_date = models.DateTimeField(
> default=timezone.now)
> published_date = models.DateTimeField(
> blank=True, null=True)
>
> def publish(self):
> self.published_date = timezone.now()
> self.save()
>
> def __str__(self):
> return self.title
> def approved_comments(self):
> return self.comments.filter(approved_comment=True)
>
> class Comment(models.Model):
> post = models.ForeignKey('post.Post', on_delete=models.CASCADE, related_name='comments')
> name = models.CharField(max_length=200)
> text = models.TextField()
> email=models.EmailField(null=True)
> created_date = models.DateTimeField(default=timezone.now)
> approved_comment = models.BooleanField(default=False)
>
> def approve(self):
> self.approved_comment = True
> self.save()
>
> def __str__(self):
> return self.text
【问题讨论】:
-
很遗憾没有
-
@seagull13 我的回答有帮助吗?
标签: python django django-models django-migrations django-manage.py