Re: Dynamically Passing Variables Into The Serializer

2019-03-13 Thread Joseph Peck
I had already found the resources that Gonazlo provided, but Jurgis' information opened my eyes that I may not have been implementing it correctly. It seems my concrete views are not suitable and I'll need to create some custom views with custom mixins. I hope to report back with success soon. Than

Re: Dynamically Passing Variables Into The Serializer

2019-03-13 Thread Jurgis Pralgauskis
I had similar dilemma working with nested routers -- needed url-kwargs to be included directly as Serializer fields. and made extra Mixin for ViewSet (actually for CreateModelMixin), which extends `get_serializer` -- a function, which takes same arguments as Serializer (and usually just injects `co

Re: Dynamically Passing Variables Into The Serializer

2019-03-11 Thread Gonzalo Amadio
Hi Joseph, does this work? https://www.django-rest-framework.org/api-guide/serializers/#including-extra-context https://micropyramid.com/blog/django-rest-framework-send-extra-context-data-to-serializers/ El lun., 11 mar. 2019 a las 14:31, Joseph Peck () escribió: > Even though it was tangential

Re: Dynamically Passing Variables Into The Serializer

2019-03-10 Thread Joseph Peck
Even though it was tangential lines of code showing proper use of the variable I want to pass into the serializer, I had a typo in the views.py example. The "State" object collection being queried on line 6 was supposed to "City." #... class DependentCityList(generics.ListCreateAPIView): d

Dynamically Passing Variables Into The Serializer

2019-03-10 Thread Joseph Peck
*Objective: Restrict the length of the choices of the browseable API field dropdown.* Technique: Filter the queryset of the serializer. *Problem: Passing a variable into the serializer.* For this example, let us say I am dealing with states and cities. I want to add a new city, but I already know