Gist 8479609
✓ Published0🌍 Public
Aandybak
Last edited Jan 17, 2014
Created on Jan 17, 2014
This example shows a Django REST Framework serializer that exposes booking data alongside a dynamic list of salesperson options. The `BookingSerializer` model serializer outputs fields for booking ID, booking number, current salesperson, and a custom `sales_people_options` field. The `UserOptionsField` uses the `field_to_native` method to query all users and return their IDs and usernames, providing a dropdown-style selection list in the API response. It relies on Django’s ORM and the `serializers.ModelSerializer` and `serializers.Field` classes from Django REST Framework.
AI-generated description