You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
574 B
16 lines
574 B
from rest_framework import serializers
|
|
from locations_api.serializers_base import LocationSerializerBase
|
|
from .models import Company
|
|
|
|
class CompanySerializerBase(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = Company# tell django which model to use
|
|
fields = ('id', 'name', 'industry',) # tell django which fields to include
|
|
|
|
class CompanySerializerWithHeadquarters(CompanySerializerBase):
|
|
headquarters = LocationSerializerBase()
|
|
|
|
class Meta(CompanySerializerBase.Meta):
|
|
fields = CompanySerializerBase.Meta.fields + ('headquarters',)
|
|
|