'enricoba' via Django REST framework
2018-10-30 15:55:55 UTC
Hi,
I am fairly new to Django REST framework, but mid experienced with native
Django. First I have a basic question regarding serializers (see picture -
using the REST framework tutorial info). For my understanding the
serializer transforms a Django queryset into a âreadableâ JSON. Therefore,
I am not sure what is happening in step 7 and 8 (hoping my assumptions are
correct). Is the serializer defining which fields of the querysets shall be
serialized? So I donât know why it has to look into Models again.
Beside of this general question, I have a special setup of data. In
addition to storing raw data, I store hash strings of my payload in each
record (own field "checksum"). I do this to notice data manipulation on
database level (there is a pepper from the application layer included).
However, I would like to add a custom field to all of my API calls that
provides a bool telling that the payload was not manipulated (compare
payload + pepper with hash). As from what I have learned until now, I could
do this by adding a custom field to the Model that I can call via the
serializer. Unfortunately, when doing so I only can access the Model
object, not the Manager of the Model. Therefore, I can only explicitly call
model fields, but not generic. Now my question is if this is even the
correct point of access? Or should / can I deal with this on the view level?
Thanks for any advice!
[image: RESTapi.png]
I am fairly new to Django REST framework, but mid experienced with native
Django. First I have a basic question regarding serializers (see picture -
using the REST framework tutorial info). For my understanding the
serializer transforms a Django queryset into a âreadableâ JSON. Therefore,
I am not sure what is happening in step 7 and 8 (hoping my assumptions are
correct). Is the serializer defining which fields of the querysets shall be
serialized? So I donât know why it has to look into Models again.
Beside of this general question, I have a special setup of data. In
addition to storing raw data, I store hash strings of my payload in each
record (own field "checksum"). I do this to notice data manipulation on
database level (there is a pepper from the application layer included).
However, I would like to add a custom field to all of my API calls that
provides a bool telling that the payload was not manipulated (compare
payload + pepper with hash). As from what I have learned until now, I could
do this by adding a custom field to the Model that I can call via the
serializer. Unfortunately, when doing so I only can access the Model
object, not the Manager of the Model. Therefore, I can only explicitly call
model fields, but not generic. Now my question is if this is even the
correct point of access? Or should / can I deal with this on the view level?
Thanks for any advice!
[image: RESTapi.png]
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.