How I can hold Profile details and them save it after provide the user
field details, Cn you tell me how i can do that?

Thank you

Regards,
Soumen

On Sun, Jul 28, 2019 at 2:22 PM Pradeep Sukhwani <[email protected]>
wrote:

> Hi Soumen,
>
> ModelSerializers do not behave in exactly the same way as ModelForm. However,
> there are intentional design decisions behind these differences. commit is
> not (and won't ever be) a keyword argument to save().
>
>
> I believe that the usage of .save() is pretty much adequately documented
> here
> <http://www.django-rest-framework.org/api-guide/serializers/#saving-instances>
> .
>
>
> On Sunday, July 28, 2019 at 2:14:31 PM UTC+5:30, Soumen Khatua wrote:
>>
>> Hi Folks,
>>
>> I'm getting this error when I declared like this:
>>
>>
>> def post(self, request):
>>         serializer = ProfileSerializer(data=request.data)
>>         username = request.user.username
>>         user_details = User.objects.get(username = username)
>>         if serializer.is_valid():
>>             serializer_data = serializer.save(commit=False)
>>             serializer_data.user = user_details
>>             serializer_data.save()
>>
>>  File
>> "/home/sou/halanx/env/lib/python3.6/site-packages/rest_framework/serializers.py",
>> line 188, in save
>>     "'commit' is not a valid keyword argument to the 'save()' method. "
>> AssertionError: 'commit' is not a valid keyword argument to the 'save()'
>> method. If you need to access data before committing to the database then
>> inspect 'serializer.validated_data' instead. You can also pass additional
>> keyword arguments to 'save()' if you need to set extra attributes on the
>> saved model instance. For example: 'serializer.save(owner=request.user)'.'
>>
>>
>> please help me guys for this issue!!!
>>
>> Thank You
>>
>> Regards,
>> Soumen
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/38571245-f03d-454b-8d8b-5258af7ee8b3%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/38571245-f03d-454b-8d8b-5258af7ee8b3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPUw6Wbi9f_LVkuLAqY_ttBZCRnmN99Ui%2BCADdhsxWZwaxm1zw%40mail.gmail.com.

Reply via email to