ccdb-api/ccdb/utils/serializers.py
Matthew Dillon 910d3b4beb Admin Section API (#11)
Models for managing admin pages
2016-09-05 17:03:01 -07:00

20 lines
555 B
Python

from rest_framework import serializers
from .models import AdminSection, AdminEntry
class AdminSectionSerializer(serializers.ModelSerializer):
class Meta:
model = AdminSection
fields = ('id', 'name', 'sort')
class AdminEntrySerializer(serializers.ModelSerializer):
class Meta:
model = AdminEntry
fields = ('id', 'admin_url', 'package', 'model', 'section', 'sort')
admin_url = serializers.SerializerMethodField()
def get_admin_url(self, obj):
return obj.admin_url(self.context.get('request'))