Django Rest Framework: how to set a custom name form non_field_errors?
<p>I'm validating if user that is registering on my website is giving me unique address (city, street, street number etc.) and when it's not unique, then I'm raising <code>serializers.ValidationError</code>:</p>

<pre><code>class UserSerializer(serializers.ModelSerializer):
   def validate(self, attrs):
        city = attrs['city']
        street = attrs['street']
        street_number = attrs['street_number']
        apartment_number = attrs['apartment_number'] if 'apartment_number' in attrs else None
        unique = check_address_unique(city, street, street_number, apartment_number)
        if not unique:
            raise serializers.ValidationError(_('Another user has already been registered under this address.'))
        return attrs
</code></pre>

<p>The problem is that the field name under which the error is passed is this standard <code>non_field_errors</code>:</p>

<p><code>{"non_field_errors":["Another user has already been registered under this address."]}</code></p>

<p>I'd like to somehow give this error a custom name, so the desired output would be:</p>

<p><code>{"address":["Another user has already been registered under this address."]}</code></p>

<p>How to accomplish that?</p>