We are going to create UserProfile(AbstractUser) and using ManyToMany relation in it.

model.py

In this I am using many to many field by (“self”) but if you want to create other model you can create it will work fine.

serializers.py

Here I am using email in place of id . for that I have created NameSerializer . You can use id also it will work fine . the most important part is that update function . this update function work when put request id called . first it delete all the previous instances and then by the help of the serializer it take the data of many to many field . After that we are using for loop and one by one inserting all the data in that instance ., at last returning instance.

views.py

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Karthiksharma
Karthiksharma

Written by Karthiksharma

I’m a Mobile Developer enthusiast & a junior pursuing my Bachelors in Computer Science . I am passionate about Data Structure, Web Dev, Machine Learning.

No responses yet

Write a response