Last active
April 23, 2018 20:39
-
-
Save CITGuru/b46c023bf22f5342d0ba4c60ad6de220 to your computer and use it in GitHub Desktop.
TicketAPI Medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import serializers | |
from django.contrib.auth.models import User | |
from tickets.models import Ticket, Category | |
# Serializers define the API representation. | |
class UserSerializer(serializers.HyperlinkedModelSerializer): | |
class Meta: | |
model = User | |
fields = ('url', 'username', 'email', 'is_staff') | |
# Serializers define the API representation. | |
class TicketSerializer(serializers.HyperlinkedModelSerializer): | |
class Meta: | |
model = Ticket | |
fields = ('id','title', 'ticket_id','user', 'content', 'category','created', 'modified') | |
# Serializers define the API representation. | |
class CategorySerializer(serializers.HyperlinkedModelSerializer): | |
class Meta: | |
model = Category | |
fields = ('name', 'slug') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment