[Answered ]-Custom field – got multiple values for keyword argument 'related_name'

1👍

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

class RsftCountryField(models.ForeignKey):
    def __init__(self, verbose_name=None, **kwargs):
        kwargs['verbose_name'] = verbose_name or 'Krajina'
        to = 'addresses.Country'
        on_delete = kwargs.pop('on_delete',None) or models.PROTECT
        related_name = kwargs.pop('related_name', None) or '+'
        super().__init__(
            to,
            on_delete,
            related_name=related_name,
            related_query_name=None,
            limit_choices_to=None,
            parent_link=False,
            to_field=None,
            db_constraint=True,
            **kwargs
        )

    def deconstruct(self):
        name, path, args, kwargs = super().deconstruct()
        kwargs.pop('to', None)
        kwargs.pop('related_query_name', None)
        kwargs.pop('limit_choices_to', None)
        kwargs.pop('parent_link', None)
        kwargs.pop('to_field', None)
        kwargs.pop('db_constraint', None)
        return name, path, args, kwargs

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

Leave a comment