Wanderley S
2018-05-15 11:20:37 UTC
I'm not quite sure if I got it right, but I believe that the correct is to
"create" the object first.
Doesn't make to much sense handle an object that is not yet persisted into
the database.
If you want the data, you could get it with:
data_to_be_saved = self.request.data
or, even better:
data_to_be_saved = serializer.validated_data
Take a look at this:
https://github.com/encode/django-rest-framework/issues/2207
Also, take a look here for the CreateModelMixin:
http://www.cdrf.co/3.7/rest_framework.viewsets/ModelViewSet.html
Hope it helps, somehow.
Regards!
"create" the object first.
Doesn't make to much sense handle an object that is not yet persisted into
the database.
If you want the data, you could get it with:
data_to_be_saved = self.request.data
or, even better:
data_to_be_saved = serializer.validated_data
Take a look at this:
https://github.com/encode/django-rest-framework/issues/2207
Also, take a look here for the CreateModelMixin:
http://www.cdrf.co/3.7/rest_framework.viewsets/ModelViewSet.html
Hope it helps, somehow.
Regards!
I'm trying to do some custom activities in a ModelViewSet
'perform_create', and I was wondering what the best way to convert
request.data URLs into objects.
for example
{
"Example": "http://localhost:8000/rest/example/30/",
}
How can I convert the string there into an object without going into the
serializer?
queryset = Connection.objects.all()
serializer_class = ConnectionSerializer
* # how do I get the specific example object here from the URL
passed in*
example_object.do_something()
instance = serializer.save()
--
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
For more options, visit https://groups.google.com/d/optout.
'perform_create', and I was wondering what the best way to convert
request.data URLs into objects.
for example
{
"Example": "http://localhost:8000/rest/example/30/",
}
How can I convert the string there into an object without going into the
serializer?
queryset = Connection.objects.all()
serializer_class = ConnectionSerializer
* # how do I get the specific example object here from the URL
passed in*
example_object.do_something()
instance = serializer.save()
--
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
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.
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.