Created
July 12, 2021 13:59
-
-
Save godfather68/501d48d60e88b2ed1966b3a8e835fb37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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