Skip to content

quickstart example and groups #2192

@highpost

Description

@highpost

After reading through #1249 and #1550 , I got the quickstart example working w/ 3.0. serializers.py looks like this now:

from django.contrib.auth.models import User, Group
from rest_framework import serializers

class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        lookup_field = 'username' 
        fields = ('username', 'email')

class GroupSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Group
        lookup_field = 'name' 
        fields = ('name')

Note that I removed the url and groups fields and added lookup_field from the source included in the quickstart tutorial on django-rest-framework.org. This works for the following URLs:

localhost/tutorial/quickstart/
localhost/tutorial/quickstart/users
localhost/tutorial/quickstart/users/1

But I haven't had any luck getting the groups api to work:

localhost/tutorial/quickstart/groups
localhost/tutorial/quickstart/groups/1

I get the following exception for both groups and groups/1
ImproperlyConfigured at /quickstart/groups/
Field name n is not valid for model ModelBase.

I've added user, groups, etc. with the Django admin console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions