serializers.py 382 B

1234567891011121314
  1. from django.contrib.auth.models import User, Group
  2. from rest_framework import serializers
  3. class UserSerializer(serializers.HyperlinkedModelSerializer):
  4. class Meta:
  5. model = User
  6. fields = ['url', 'username', 'email', 'groups']
  7. class GroupSerializer(serializers.HyperlinkedModelSerializer):
  8. class Meta:
  9. model = Group
  10. fields = ['url', 'name']