-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setting the fields description if you are using function based views #119
Comments
@Dean-Christian-Armada Did you solve this? |
Actually no, I switched to class-based views |
Ok. I imagine as there is not a |
Exactly, besides I found out that the class-based view is much better |
I am working with the DRF and got struck at this point. I am using fuction based views , and I am not getting the details of input parameters in API doc page. Please help on this one , if someone came across it. |
@niscp have you found a solution ? |
So, if you are using a decorator like So there is a way to get a docstring out of Basically you need to rewrite
|
How do I set the field descriptions in views.py on function based views?
This is my syntax:
@api_view(['GET', 'POST'])
def api_section(request):
"""
GET request gets the section and its details..... POST request, adds a new section
"""
if request.method == 'GET':
sections = Section.objects.all()
serializer = SectionSerializer(sections, many=True)
return Response(serializer.data)
Field descriptions seems to work smoothly by declaring a serializer_class variable in class-based views that inherits APIView like this one:
class ObtainAuthToken(APIView):
throttle_classes = ()
permission_classes = ()
parser_classes = (parsers.FormParser, parsers.MultiPartParser, parsers.JSONParser,)
renderer_classes = (renderers.JSONRenderer,)
serializer_class = AuthTokenSerializer
The text was updated successfully, but these errors were encountered: