I am using django rest framework to post property_id in favorites table as a foreign key and on the basis of foreign key i want to get all fields from property table.
class Favorites(models.Model):
"""Store favorite property"""
user_id = models.ForeignKey(User, on_delete=models.CASCADE)
property_id = models.ForeignKey(Property, on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True, blank=True)
Serializer:
class FavoriteSerializer(serializers.ModelSerializer):
"""Favorite Properties serializer"""
class Meta:
model = Favorites
fields = ('user_id','property_id', )
Viewset:
class FavoriteViewSet(viewsets.ModelViewSet):
http_method_names = ['get','post' ]
serializer_class = FavoriteSerializer
queryset = Favorites.objects.all()
This is my first output. then i sync my property Serializer and get this one:
This is the output i need but it creates problem during post. During post i only need user_id and property_id but it makes my post form like this:
Any suggestions how i can achieve my results?



raw dataright fromhtml form?