Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InvalidBasesError: Cannot resolve bases for [<ModelState: 'users.GroupProxy'>]

When I run tests I get this error during database initialization:

django.db.migrations.state.InvalidBasesError: Cannot resolve bases for [<ModelState: 'users.GroupProxy'>] This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth) 

I created this proxy for contrib.auth Group model to place it in my app in django admin:

class GroupProxy(Group):     class Meta:         proxy = True         verbose_name = Group._meta.verbose_name         verbose_name_plural = Group._meta.verbose_name_plural 

So what can I do to fix this issue?

like image 529
Dmitrii Mikhailov Avatar asked May 15 '15 19:05

Dmitrii Mikhailov


2 Answers

After a lot of digging on this the only thing that worked for me was

comment out the offending apps, run migrations, then add them in again.

Just a workaround but hopefully it helps somebody.

like image 158
dlsso Avatar answered Sep 20 '22 02:09

dlsso


Simply creating a migrations directory at the root of your app (so users/migrations/ in your case) and adding an empty __init__.py file might resolve your issue. At least it did for me when I was getting the same error.

But you're better off running makemigrations for your app, as suggested by @zenofewords above. That will create the directory for you AND generate migrations for your proxy models.

Why does Django create migration files for proxy models?

Your tests are looking for those migrations and aren't finding them.

like image 21
tino Avatar answered Sep 20 '22 02:09

tino