Skip to content

Instantly share code, notes, and snippets.

@andybak
Created January 17, 2014 19:16
Show Gist options
  • Save andybak/8479609 to your computer and use it in GitHub Desktop.
Save andybak/8479609 to your computer and use it in GitHub Desktop.
class BookingSerializer(serializers.ModelSerializer):
class UserOptionsField(serializers.Field):
def field_to_native(self, obj, field_name):
return User.objects.all().values('id', 'username')
sales_people_options = UserOptionsField()
class Meta:
model = Booking
fields = (
'id', 'booking_no', 'current_salesperson', 'sales_people_options',
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment