serializers.py 458 Bytes
Newer Older
1 2 3 4 5
"""
go/serializers.py

Define how data is translated from the database to json/API representation.
"""
David Haynes's avatar
David Haynes committed
6 7 8 9
# App Imports
from .models import URL, RegisteredUser

# Third Party Imports
10
from rest_framework import serializers
David Haynes's avatar
David Haynes committed
11 12
from rest_framework.authtoken.models import Token

13

David Haynes's avatar
David Haynes committed
14
class URLSerializer(serializers.HyperlinkedModelSerializer):
15
    class Meta:
David Haynes's avatar
David Haynes committed
16
        model = URL
David Haynes's avatar
David Haynes committed
17 18 19
        lookup_field = "short"
        fields = ("destination", "short", "date_expires")