Skip to content

Instantly share code, notes, and snippets.

@godfather68
Created July 12, 2021 13:59
Show Gist options
  • Save godfather68/501d48d60e88b2ed1966b3a8e835fb37 to your computer and use it in GitHub Desktop.
Save godfather68/501d48d60e88b2ed1966b3a8e835fb37 to your computer and use it in GitHub Desktop.
from django.db.models import query
from rest_framework import serializers
from core.models import House
class HouseSerializer(serializers.ModelSerializer):
"""Serializer for the House ad object"""
options = serializers.PrimaryKeyRelatedField(
queryset=Options.objects.all()
)
location = serializers.PrimaryKeyRelatedField(
queryset=District.objects.all()
)
class Meta:
model = House
fields = ('id', 'title', 'price', 'description','options', 'location', 'furnished')
read_only_fields = ('id', )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment