Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 312
Paul Exconde Avatar asked Nov 21 '25 20:11

Paul Exconde


1 Answers

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
        ),
    ]
like image 107
Nofal Avatar answered Nov 24 '25 09:11

Nofal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!