How do you save a foreign key instance

I have this profile model:

```
class Profile(models.Model):

    # Gender
    M = 'M'
    F = 'F'
    O = 'O'
    GENDER = [ 
        (M, "male"),
        (F, "female"),
        (O, "Other")
    ]

    # Basic information
    background = models.FileField(upload_to=background_to, null=True, blank=True)
    photo = models.FileField(upload_to=image_to, null=True, blank=True)
    slug = AutoSlugField(populate_from=['first_name', 'last_name', 'gender', 'location'])
    first_name = models.CharField(max_length=100)
    middle_name = models.CharField(max_length=100, null=True, blank=True)
    last_name = models.CharField(max_length=100)
    birthdate = models.DateField()
    gender = models.CharField(max_length=1, choices=GENDER, default=None)
    bio = models.TextField(max_length=5000, null=True, blank=True)
    languages = ArrayField(models.CharField(max_length=30, null=True, blank=True))

    # Location information
    website = models.URLField(max_length=256, null=True, blank=True)

    # author information 
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="created at")
    updated_at = models.DateTimeField(auto_now=True, verbose_name="updated at")

    class Meta:
        verbose_name = "profile"
        verbose_name_plural = "profiles"
        db_table = "user_profiles"

    def __str__(self):
        return self.first_name + ' ' + self.last_name

    def get_absolute_url(self):
        return self.slug    
```

and this serializer for the model:

from rest_framework import serializers
from .models import *

class ProfileSerializer(serializers.ModelSerializer):

    class Meta:
        model = Profile
        fields = [
            "id",
            "background",
            "photo",
            "first_name",
            "middle_name",
            "last_name",
            "birthdate",
            "gender",
            "bio",
            "languages",
            "website",
            "user",
            "created_at",
            "updated_at",
        ]

and lastly this view to get the data:

class MyProfile(generics.RetrieveAPIView):
    
    permission_classes = [permissions.IsAuthenticated]

    serializer_class = ProfileSerializer
    name = "my-profile"

    lookup_field = "user"

    def get_queryset(self):
        id = self.kwargs["user"]

        return Profile.objects.all().filter(user_id=id)

Why am I not seeing the profile ID in the JSON data returned from the view? I really need the ID to do things with but it is not showing and I don’t understand why not

Maybe you could post your output. Also why are you using filter() instead of get()?

I solved it thank you