Django 1.7.1的迁移错误 [英] Migration error with Django 1.7.1

查看:187
本文介绍了Django 1.7.1的迁移错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在导入新应用程序(django-allauth)后执行迁移时,我收到错误。我不知道还有什么要尝试来修复错误。



当运行 manage.py migrate

时,我尝试了一些事情,但似乎并不令人遗憾。

 文件D:\Python27\Lib\site-packages\django\db\migrations\state.py ,第71行,
在渲染中提高
InvalidBasesError(无法解析%r\\\
的基础如果您从具有迁移的应用程序(例如contrib.auth)继承
模型,则可能会发生这种情况\\ n在没有迁移的应用程序中;
有关更多%
new_unrendered_models,请参阅https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies
django。 db.migrations.state.InvalidBasesError:无法解析
的基础[< ModelState:'blog.BlogPage'>< ModelState:'blog.BlogIndexPage'>]
如果您从应用程序继承模型,在没有迁移的应用程序中迁移
(例如contrib.auth);请参阅
https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies了解更多

models.py

 从django.db导入模型
从wagtail.wagtailcore.models导入页面,可从wagtail.wagtailcore.fields导入订单
RichTextField
来自wagtail.wagtailadmin.edit_handlers import FieldPanel,MultiFieldPanel,InlinePanel,PageChooserPanel
from modelcluster.fields import ParentalKey

class BlogPage(Page):
body = RichTextField()
date = models.DateField(Post date)
indexed_fields =('body',)
search_name =Blog page

BlogPage.content_panels = [
FieldPanel('title',classname =full title),
FieldPanel('date' ),
FieldPanel('body',classname =full),
]


class LinkFields(models.Model):
link_page = models.ForeignKey(
'wagtailcore.Page ,
null = True,
blank = True,
related_name ='+'


panels = [
PageChooserPanel('link_page '),
]

class Meta:
abstract = True

class RelatedLink(LinkFields):
title = models.CharField max_length = 255,help_text =链接标题)
面板= [
FieldPanel('title'),
MultiFieldPanel(LinkFields.panels,Link),
]

class Meta:
abstract = True


class BlogIndexPageRelatedLink(Orderable,RelatedLink):
page = ParentalKey('blog.BlogIndexPage' ,related_name ='related_links')

class BlogIndexPage(页):
intro = models.CharField(max_length = 256)
indexed_fields =('body',)
search_name =博客索引页

BlogIndexPage.content_panels = [
FieldPanel('title',classname =full title),
FieldPanel('intro',cla ssname =full),
InlinePanel(BlogIndexPage,'related_links',label =相关链接),
]

我迄今为止所尝试的:


  1. 建议: https://stackoverflow.com/a/25858659 ,但这并没有改变任何东西给我。

  2. 我也尝试过 https:// code.djangoproject.com/ticket/22051#comment:12 ,没有成功。

注意: / strong> makemigrations运行(没有检测到变化),但迁移失败。



平台设置:这是目前在Windows上的Django 1.7.1框。



有没有人遇到过这个问题,有没有修复?



提前感谢



---发出命令顺序如下:

 (env)D:\git\rebootv2.1\blog> python manage.py migrate 
D:\Python27\\ \\ Lib\site-packages\treebeard\mp_tree.py:102:RemovedInDjango18Warning:`MP_NodeManager.get_query_set`方法
应该被重命名为`get_queryset`。
类MP_NodeManager(models.Manager):

要执行的操作:
同步未迁移的应用程序:帐户,allauth,modelcluster,博客,压缩器,Facebook,wagtailsnippets,socialaccount
应用所有迁移:core,wagtailusers,wagtailembeds,wagtailadmin,sessions,admin,wagtailcore,sites,auth,contenttypes,wagtaildocs,taggit,wagtailsearch,wagtailforms,wagtailredirects,wagtailimages
同步不需要迁移的应用程序:
创建表...
安装自定义SQL ...
安装索引...
运行迁移:
应用sites.0001_initial ...追溯(最近最近的呼叫):
文件manage.py,第10行,在< module>
execute_from_command_line(sys.argv)
文件D:\Python27\Lib\site- packages\django\core\management\__init __。py,第385行,在execute_from_command_line
utility.execute()
文件D:\Python27\Lib\site- packages\django\core\management\__init __。py,第377行,执行
self.fetch_command(子命令).run_from_argv(self.argv)
文件D:\Python27\Lib\site-packages\django\core\management\base.py ,第288行,在run_from_argv
self.execute(* args,** options .__ dict__)
文件D:\Python27\Lib\site- packages\django\core\管理\base.py,行338,执行
output = self.handle(* args,** options)
文件D:\Python27\Lib\site-packages \\ django\core\management\commands\migrate.py,第160行,处理
executor.migrate(targets,plan,fake = options.get(fake,False) )
文件D:\Python27\Lib\site- packages\django\db\migrations\executor.py,第63行迁移
self.apply_migration(migration ,fake = fake)
文件D:\Python27\Lib\site-packages\django\db\migrations\executor.py,第91行,apply_migration
if self.detect_soft_applied(migration):
文件D:\Python27\Lib\site-packages\django\db\migrations\executor.py,第135行,在detect_soft_applied
apps = project_state.render()
文件D:\Python27\Lib\site-packages\django\db\migrations\state.py,第71行,在render raise中InvalidBasesError (无法解决%r\\\
的基础如果您从具有迁移的应用程序继承模型,则可能会发生这种情况(例如contrib.auth)\\\
在没有迁移的应用程序中请参阅https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies了解更多%new_unrendered_models
django.db.migrations.state.InvalidBasesError:无法解析[< ModelState: 'blog.BlogPage'>< ModelState:'blog.BlogIndexPage'>]
如果您在应用程序中继承模型(例如contrib.auth)
,则可能会发生这种情况没有迁移;请参阅https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies了解更多

(env)D:\git\rebootv2.1\ blog> python manage.py makemigrations
D:\Python27\Lib\site-packages\treebeard\mp_tree.py:102:RemovedInDjango18警告:`MP_NodeManager.get_query_set`方法
应该被重命名`````````````````````````````````````` b $ b

[为我修复了什么] - 最终成为排序问题我猜.... $ /


  1. 在settings.py

  2. 中禁用INSTALLED_APPS中的所有allauth应用程序运行manage.py migrate启用所有的allauth应用程序,并禁用
    为项目生成的wagtail应用程序(例如博客)

  3. 再次运行manage.py migrate启用INSTALLED_APPS中的两组应用程序

  4. 再次运行manage.py migrate

现在似乎很开心



希望这有助于某人保存一段时间!

解决方案

最终成为排序问题,我猜....


  1. 禁用在setup.py
  2. 运行manage.py migrate启用所有的allauth应用程序,并禁用为项目生成的wagtail应用程序(例如博客)

  3. 运行manage.py migrate再次启用INSTALLED_APPS中的两套应用程序

  4. 再次运行manage.py migrate

似乎现在开心



希望这有助于某人保存一段时间!


I'm getting an error when performing a migration after introducing a new app (django-allauth). I'm not sure what else to try in order to fix the error. I've tried a few things but they don't seem to help unfortunately.

when running manage.py migrate:

File "D:\Python27\Lib\site-packages\django\db\migrations\state.py", line 71, 
in render raise     
InvalidBasesError("Cannot resolve bases for %r\nThis can happen if you are inheriting 
models from an app with migrations (e.g. contrib.auth)\n in an app with no migrations; 
see https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies for more" % 
new_unrendered_models)
django.db.migrations.state.InvalidBasesError: Cannot resolve bases for 
[<ModelState: 'blog.BlogPage'>, <ModelState: 'blog.BlogIndexPage'>]
This can happen if you are inheriting models from an app with migrations 
(e.g. contrib.auth) in an app with no migrations; see
https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies for more

models.py

    from django.db import models
    from wagtail.wagtailcore.models import Page, Orderable
    from wagtail.wagtailcore.fields import RichTextField
    from wagtail.wagtailadmin.edit_handlers import FieldPanel  ,MultiFieldPanel,InlinePanel, PageChooserPanel
    from modelcluster.fields import ParentalKey

class BlogPage(Page):
    body = RichTextField()
    date = models.DateField("Post date")
    indexed_fields = ('body', )
    search_name = "Blog Page"

BlogPage.content_panels = [
    FieldPanel('title', classname="full title"),
    FieldPanel('date'),
    FieldPanel('body', classname="full"),
]


class LinkFields(models.Model):
    link_page = models.ForeignKey(
        'wagtailcore.Page',
        null=True,
        blank=True,
        related_name='+'
    )

panels = [
    PageChooserPanel('link_page'),
]

class Meta:
    abstract = True

class RelatedLink(LinkFields):
    title = models.CharField(max_length=255, help_text="Link title")
    panels = [
         FieldPanel('title'),
         MultiFieldPanel(LinkFields.panels, "Link"),
     ]

     class Meta:
         abstract = True


 class BlogIndexPageRelatedLink(Orderable, RelatedLink):
     page = ParentalKey('blog.BlogIndexPage', related_name='related_links')

 class BlogIndexPage(Page):
     intro = models.CharField(max_length=256)
     indexed_fields = ('body', )
     search_name = "Blog Index Page"

 BlogIndexPage.content_panels = [
     FieldPanel('title', classname="full title"),
     FieldPanel('intro', classname="full"),
     InlinePanel(BlogIndexPage, 'related_links', label="Related links"),
 ]    

What I've tried so far:

  1. followed the advice here: https://stackoverflow.com/a/25858659 however this has not changed anything for me.
  2. I've also tried https://code.djangoproject.com/ticket/22051#comment:12 with no success.

note: makemigrations runs (no changes detected) but migrate fails.

platform setup: This is currently on Django 1.7.1 on a Windows box. django-allauth runs successfully within other apps on this box.

Has anyone come across this before and is there a fix?

thanks in advance

---issued command sequence below:

     (env) D:\git\rebootv2.1\blog>python manage.py migrate
     D:\Python27\Lib\site-packages\treebeard\mp_tree.py:102: RemovedInDjango18Warning:      `MP_NodeManager.get_query_set` method
 should be renamed `get_queryset`.
   class MP_NodeManager(models.Manager):

 Operations to perform:
   Synchronize unmigrated apps: account, allauth, modelcluster, blog, compressor, facebook,      wagtailsnippets, socialaccount
   Apply all migrations: core, wagtailusers, wagtailembeds, wagtailadmin, sessions, admin,      wagtailcore, sites, auth, contenttypes, wagtaildocs, taggit, wagtailsearch, wagtailforms,      wagtailredirects, wagtailimages
 Synchronizing apps without migrations:
   Creating tables...
   Installing custom SQL...
   Installing indexes...
 Running migrations:
   Applying sites.0001_initial...Traceback (most recent call last):
   File "manage.py", line 10, in <module>
     execute_from_command_line(sys.argv)
   File "D:\Python27\Lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
   File "D:\Python27\Lib\site-packages\django\core\management\__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
   File "D:\Python27\Lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
   File "D:\Python27\Lib\site-packages\django\core\management\base.py", line 338, in execute
output = self.handle(*args, **options)
   File "D:\Python27\Lib\site-packages\django\core\management\commands\migrate.py", line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
   File "D:\Python27\Lib\site-packages\django\db\migrations\executor.py", line 63, in migrate
self.apply_migration(migration, fake=fake)
   File "D:\Python27\Lib\site-packages\django\db\migrations\executor.py", line 91, in apply_migration
if self.detect_soft_applied(migration):
   File "D:\Python27\Lib\site-packages\django\db\migrations\executor.py", line 135, in detect_soft_applied
apps = project_state.render()
   File "D:\Python27\Lib\site-packages\django\db\migrations\state.py", line 71, in render raise InvalidBasesError("Cannot resolve bases for %r\nThis can happen if you are inheriting models from an app with migrations (e.g. contrib.auth)\n in an app with no migrations; see https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies for more" % new_unrendered_models)
 django.db.migrations.state.InvalidBasesError: Cannot resolve bases for [<ModelState: 'blog.BlogPage'>, <ModelState: 'blog.BlogIndexPage'>]
 This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth)
  in an app with no migrations; see https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies for more

 (env) D:\git\rebootv2.1\blog>python manage.py makemigrations
 D:\Python27\Lib\site-packages\treebeard\mp_tree.py:102: RemovedInDjango18Warning: `MP_NodeManager.get_query_set` method
 should be renamed `get_queryset`.
   class MP_NodeManager(models.Manager):

 No changes detected

[what fixed this for me] - ended up being a problem with sequencing I guess....

  1. disable all of the allauth apps within INSTALLED_APPS in settings.py
  2. run manage.py migrate enable all of the allauth apps and disable the wagtail app that was generated for the project (e.g. blog)
  3. run manage.py migrate again enable both sets of apps in INSTALLED_APPS
  4. run manage.py migrate again

seems to be happy now.

hope this helps someone and saves them some time!

解决方案

ended up being a problem with sequencing I guess....

  1. disable all of the allauth apps within INSTALLED_APPS in settings.py
  2. run manage.py migrate enable all of the allauth apps and disable the wagtail app that was generated for the project (e.g. blog)
  3. run manage.py migrate again enable both sets of apps in INSTALLED_APPS
  4. run manage.py migrate again

seems to be happy now.

hope this helps someone and saves them some time!

这篇关于Django 1.7.1的迁移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆