Change django object name
<p>I have <code>UserDetailsSerializer</code> class as shown below. I would like to change it's object name from user to data to meet API endpoint requirements on my front-end application. I tried searching through internet but wasn't quite sure how to get such result. </p>

<pre><code>class UserDetailsSerializer(serializers.ModelSerializer):
    uid = serializers.SerializerMethodField('get_username')

    """
    User model w/o password
    """
    class Meta:
        model = UserModel
        fields = ('uid', 'email', 'first_name', 'last_name', 'id')
        read_only_fields = ('email', )

    def get_username(self, obj):
        return obj.username
</code></pre>

<p>There are few other methods that I could think of, which are reassigning the object in the view with a different name (again, I'm not exactly sure how it works with serializers.) and changing the front-end application API requirement. Please let me know if you can help.</p>

<p>You haven't provided the content of your view. I believe currently the response dict that your are returning is something like:</p>

<pre><code>{'user': UserDetailsSerializer(your_object).data}
</code></pre>

<p>In this replace the key <code>user</code> with <code>data</code>.</p>

<p>If that is not the case, please mention where is <code>user</code> defined?</p>

python django django-rest-framework django-rest-auth