Can't get the APIView HTML form to show up #9036
-
I recently got a new job and I'm learning Django for it. I've been following this tutorial on how to connect it to a React frontend. There is a shorter and more recent version of this tutorial here. In this part of the first linked video above, he sets up a class based view using Not sure what I'm missing. My app's models.py:
My app's serializers.py:
My app's views.py:
My project's urls.py:
What gets generated by the view: EDIT: modified code blocks so they would show up correctly |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you are building an API, then this should be expected. You have likely navigated to the DRF endpoint which is giving you a nice view of the contents of your employee model, serializer and Class View code for the GET endpoint specifically. What you would want to do is set up your react side of things to consume the contents of the APIView you just made. Use a tool like Axios or Fetch and hit the endpoint you have here and it will return to you the employees you have in your Employee model. Which it also. looks like you may want to seed your DB with some employees. |
Beta Was this translation helpful? Give feedback.
If you are building an API, then this should be expected. You have likely navigated to the DRF endpoint which is giving you a nice view of the contents of your employee model, serializer and Class View code for the GET endpoint specifically. What you would want to do is set up your react side of things to consume the contents of the APIView you just made. Use a tool like Axios or Fetch and hit the endpoint you have here and it will return to you the employees you have in your Employee model. Which it also. looks like you may want to seed your DB with some employees.