Commit de0a9f0e authored by Luis García's avatar Luis García
Browse files

Add asymetric fields on state, city and suburb models

parent 654e02c6
......@@ -6,6 +6,7 @@ from django.utils.translation import gettext as _
from rest_framework import serializers
from rest_framework.serializers import SerializerMethodField
from drf_extra_fields.geo_fields import PointField
from api.utils import AsymetricRelatedField
from core.models import Profile, Map, Country, State, City, Suburb
from core.forms import PasswordResetForm
import json
......@@ -121,16 +122,32 @@ class CountrySerializer(serializers.ModelSerializer):
fields = ('id', 'name')
class StateSerializer(serializers.ModelSerializer):
country = AsymetricRelatedField.from_serializer(CountrySerializer)()
class Meta:
model = State
fields = ('id', 'name', 'country')
class StateSerializer_temp(serializers.ModelSerializer):
class Meta:
model = State
fields = ('id', 'name', 'country')
class CitySerializer(serializers.ModelSerializer):
state = AsymetricRelatedField.from_serializer(StateSerializer_temp)()
class Meta:
model = City
fields = ('id', 'name', 'state')
class CitySerializer_temp(serializers.ModelSerializer):
class Meta:
model = City
fields = ('id', 'name', 'state')
class SuburbSerializer(serializers.ModelSerializer):
city = AsymetricRelatedField.from_serializer(CitySerializer_temp)()
class Meta:
model = Suburb
fields = ('id', 'name', 'city')
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment