I'm a beginner with a few months under my belt but am practically new to django.

class Locations(ViewSet):

def create(self, request):

    user = VacaUser.objects.get(user=request.auth.user)
    location = Location()
    # activity = Activity.objects.filter()

    location.user = user
    location.title = request.data["title"]
    location.time = request.data["time"]
    location.description = request.data["description"]
    location.photo = request.data["photo"]

    try:
        location.save()
        # location.set(activity)
        location.activity = Activity.objects.get(pk=request.data["activity"])
        serializer = LocationSerializer(Location, context={'request': request})
        return Response(serializer.data)
    except ValidationError as ex:
        return Response({"reason": ex.message}, status=status.HTTP_400_BAD_REQUEST)

class Location(models.Model):

time = models.DateField(models.DateField(auto_now=False, auto_now_add=False, null=True, blank=True))
user = models.ForeignKey("VacaUser", on_delete=models.DO_NOTHING, related_name="vacauser")
title = models.CharField(max_length=50)
description = models.TextField(max_length=200)
activity = models.ManyToManyField("Activity", related_name='activities', blank=True)
photo = models.ImageField(upload_to=None, height_field=None, width_field=None, max_length=100)

class Activities(ViewSet):

def create(self, request):

    activity = Activity()
    activity.name = request.data["name"]

    try:
        activity.save()
        serializer = ActivitySerializer(activity, context={'request': request})
        return Response(serializer.data)
    except ValidationError as ex:
        return Response({"reason": ex.message}, status=status.HTTP_400_BAD_REQUEST)

class Activity(models.Model):

name = models.CharField(max_length=50,)








    

       

` POSTMAN EXAMPLE : This is one of my fixtures.

{
        "id": 1,
        "time": "2018-04-12",
        "user": {
            "id": 1,
            "bio": "Me",
            "user": 1
        },
        "title": "Hawaii",
        "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mattis lectus sit amet velit viverra viverra. Cras efficitur volutpat sem.",
        "photo": "http://localhost:8000/https%3A/res.cloudinary.com/db1peeart/image/upload/v1601909566/Michael/hawaii2_jwrmwb.jpg",
        "activity": [
            {
                "id": 1,
                "name": "Swimming"
            },
            {
                "id": 2,
                "name": "Beach"
            },
            {
                "id": 3,
                "name": "Hike"
            },
            {
                "id": 5,
                "name": "Something"
            }
        ]
    }

THIS IS WHAT POSTMAN CREATES WHEN IT FAILS AND THROWS THE NETWORK ERROR:

 {
        "id": 7,
        "time": "2021-01-20",
        "user": {
            "id": 1,
            "bio": "Me",
            "user": 1
        },
        "title": "123",
        "description": "123",
        "photo": "http://localhost:8000/https%3A/res.cloudinary.com/db1peeart/image/upload/v1610379022/Michael/congressional_rep_sh1dx1.jpg",
        "activity": []
    }




This is from my FORM IN REACT, all attributes work and post/create new objects.
             The only thing that fails is "activity".
             addLocation({
                title: location.title,
                description: location.description,
                photo: photo,
                activity: parseInt([location.activity1]),
                time: location.time,
                user: userId