Skip to content
Advertisement

Custom field – got multiple values for keyword argument ‘related_name’

I’m working on a custom field that is just a shortcut to ForeignKey that points to addresses.Country model.

When I run makemigrations it returns this error with I’m not sure:

JavaScript

I understand that there are two to arguments passed but I don’t understand why. It looks like the field is initialized two times. Once with the kwargs I provided and then with all the kwargs.

JavaScript

Model:

JavaScript

It prints kwargs two times:

JavaScript

Why does it do that and how to make it work?

EDIT:

Basically, I just want to provide all the fields by default without having to specify it everytime I define the country field in model.

Advertisement

Answer

The problem is the .deconstruct() method [Django-doc], since that will :

JavaScript

You will need to make new migrations where a RsftCountryField is involved.

Advertisement