Django restapi get post

32 views
Skip to first unread message

TimT Vogt

unread,
Sep 12, 2018, 5:05:16 AM9/12/18
to django...@googlegroups.com
Hi Group
I am making an Django backend to out data with a rest API to angular frontend.

The rest-API/ GET works😀.
The POST: do I ajust the current serializer?
Or do I need to create another serializer in ABN New app with a recieving model?

Verstuurd vanaf mijn iPhone

PASCUAL Eric

unread,
Sep 12, 2018, 5:27:50 PM9/12/18
to django...@googlegroups.com

Hi,


It depends if the structure of the data you want to post is the same as the one your retrieve with a GET, and if it fits with the underlying model. In this case, the same serializer can be used for both operations. Pay attention however that things can be more complex if the involved model uses relations. In this case, using the same serializer is not always applicable.


If not possible, you'll need to define one for data retrieval (you can configure it so that all fields are read-only to be sure it will not be used incorrectly) and another one to model the data you'll send for a POST.


Eric


From: django...@googlegroups.com <django...@googlegroups.com> on behalf of TimT Vogt <timt...@gmail.com>
Sent: Wednesday, September 12, 2018 11:04:39 AM
To: django...@googlegroups.com
Subject: Django restapi get post
 
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/96859EB9-17EF-49C4-ADD6-3D912749FF5B%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages