Django 1.7.1的迁移错误

And*_*ewO 6 django django-allauth django-1.7 wagtail

在引入新应用程序(django-allauth)后执行迁移时出现错误.我不知道还有什么可以尝试以修复错误.我尝试了一些东西,但不幸的是它们似乎没有帮助.

运行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
Run Code Online (Sandbox Code Playgroud)

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"),
 ]    
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试过的:

  1. 按照这里的建议:https://stackoverflow.com/a/25858659然而这对我没有任何改变.
  2. 我也试过https://code.djangoproject.com/ticket/22051#comment:12但没有成功.

注意: makemigrations运行(未检测到更改)但迁移失败.

平台设置:目前在Windows机器上的Django 1.7.1上.django-allauth在此框中的其他应用程序中成功运行.

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

提前致谢

---下面发出命令序列:

     (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
Run Code Online (Sandbox Code Playgroud)

[这对我来说有什么问题] - 最终成为排序问题我猜...

  1. 在settings.py中禁用INSTALLED_APPS中的所有allauth应用程序
  2. 运行manage.py migrate启用所有allauth应用程序并禁用为项目生成的wagtail应用程序(例如博客)
  3. 再次运行manage.py migrate会在INSTALLED_APPS中启用这两组应用
  4. 再次运行manage.py migrate

现在似乎很开心.

希望这有助于某人并节省一些时间!

And*_*ewO 13

最终成为测序问题我猜....

  1. 在settings.py中禁用INSTALLED_APPS中的所有allauth应用程序
  2. 运行manage.py migrate启用所有allauth应用程序并禁用为项目生成的wagtail应用程序(例如博客)
  3. 再次运行manage.py migrate会在INSTALLED_APPS中启用这两组应用
  4. 再次运行manage.py migrate

现在似乎很开心.

希望这有助于某人并节省一些时间!


Tam*_*iel 5

我也有错误Cannot resolve bases for ... This can happen if you are inheriting models from an app with migrations。原因python manage.py makemigrations是未创建任何迁移文件。这是因为我没有migrations文件夹。在我添加了该文件夹(__init__.py里面是一个空的)之后,一切正常。