Not sure if this is the best way to do it, but finally got it working:
def create(self, validated_data):
postcode = validated_data.pop('postcode')
advice_areas = validated_data.pop('advice_areas')
validated_data['location'] = geo(postcode)
validated_data['postcode'] = postcode
validated_data['owner'] = self.context['request'].user
practice = Practice.objects.create(**validated_data)
practice.advice_areas.add(*advice_areas)
return practice
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.