Open kiraware opened 1 year ago
Thanks for the request.
Here's a direct link to the PhoneNumberField
serializer field docs
Thanks for your response!
Also i wanna suggest that AddressField model look something like openid connect address claim, may have a look at https://openid.net/specs/openid-connect-core-1_0.html#AddressClaim Thanks again @banagale
I use this monky patch for my project.
class AddressField(serializers.CharField):
def to_representation(self, instance):
data = {}
data['raw'] = instance.raw
data['street_number'] = instance.street_number
data['route'] = instance.route
data['latitude'] = instance.latitude
data['longitude'] = instance.longitude
if instance.locality:
data['locality'] = instance.locality.name
data['postal_code'] = instance.locality.postal_code
if instance.locality.state:
data['state'] = instance.locality.state.name
data['state_code'] = instance.locality.state.code
if instance.locality.state.country:
data['country'] = instance.locality.state.country.name
data['country_code'] = instance.locality.state.country.code
return data
def to_internal_value(self, data):
return parse_address(data)
Hello. Please add support to serialize model to support REST API in Django. Something like django-phonenumber-field package. It would be very nice if it has the ability to serialize data out of the box without implement it manually to API view endpoint