ValueError: Related model 'auth.Group' cannot be resolved when running django test

Viewed 161

I am new to Django REST Api testing and I am running an error like this raise ValueError('Related model %r cannot be resolved' % self.remote_field.model) ValueError: Related model 'auth.Group' cannot be resolved when running a test, and im not sure why this happen

2 Answers

You can solve it removing the migrations files.

I ran into the same issue when switching to custom User model mid-project. The trick is that you will need to add the below auth dependency before creating your custom user model operation


from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0012_alter_user_first_name_max_length'), # this is the missing part
    ]

    operations = [
        migrations.CreateModel(
             .... # your custom user create model operation
        ),
    ]
Related