我的models.py文件
class Dag(models.Model):
dag_id = models.CharField(primary_key=True, max_length=250)
is_paused = models.IntegerField(blank=True, null=True)
is_subdag = models.IntegerField(blank=True, null=True)
is_active = models.IntegerField(blank=True, null=True)
last_scheduler_run = models.DateTimeField(blank=True, null=True)
last_pickled = models.DateTimeField(blank=True, null=True)
last_expired = models.DateTimeField(blank=True, null=True)
scheduler_lock = models.IntegerField(blank=True, null=True)
pickle_id = models.IntegerField(blank=True, null=True)
fileloc = models.CharField(blank=True, max_length=250)
owners = models.CharField(blank=True, max_length=250)
def _str_(self):
return self.dag_id
class Meta:
managed = True
db_table = 'dag'我的serializers.py文件
class Dag_api_serializers(ModelSerializer):
class Meta:
model = Dag
fields = ('dag_id','is_paused','is_active','is_subdag','last_scheduler_run','last_pickled','last_expired','scheduler_lock','pickle_id','fileloc','owners')在给出逗号python manage.py migrate或makemigrations时,会发生以下错误。我在我的模型中有一个db表,我希望它们通过我提到的最后几行错误消息的command...here迁移。
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\env\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
utility.execute()
File "C:\env\lib\site-packages\django\core\management\__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\env\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\env\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "C:\env\lib\site-packages\django\core\management\commands\makemigrations.py", line 96, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File "C:\env\lib\site-packages\django\db\migrations\loader.py", line 52, in __init__
self.build_graph()
File "C:\env\lib\site-packages\django\db\migrations\loader.py", line 203, in build_graph
self.load_disk()
File "C:\env\lib\site-packages\django\db\migrations\loader.py", line 117, in load_disk
"Migration %s in app %s has no Migration class" % (migration_name, app_config.label)
django.db.migrations.exceptions.BadMigrationError: Migration serializers in app snippets has no Migration class在模型中,我指的是已经存在的表格。
发布于 2021-07-30 11:45:41
好的,这个错误只发生在您已经完成了生成,但还没有迁移文件,后来删除了模型类,所以为了解决这个问题,您需要到应用程序文件夹中查找迁移文件夹,并选择尚未迁移或最近启动的迁移文件!只需删除该文件并再次重新启动服务器:),我自己用这种方法解决了这个问题,这样也可以帮助您,这比创建一个新应用程序和进行迁移更好。
https://stackoverflow.com/questions/45565133
复制相似问题