Agu Aguilar
2018-10-11 17:48:14 UTC
Hi there!
I have a model:
from django.contrib.sites.models import Site
class Person(models.Model):
site = ForeignKey(Site, on_delete=models.CASCADE)
I have two serializers:
from .models import Person
from django.contrib.sites.models import Site
class PersonSerializer(serializers.ModelSerializer):
class Meta:
fields = '__all__'
model = Person
class SiteSerializer(serializers.ModelSerializer):
class Meta:
fields = '__all__'
model = Site
I have a model view set
from .serializers import PersonSerializer
class PersonViewSet(viewset.ModelViewSet):
pass
How I would do to get all person that have a associate site from this url
"/api/site/{site_id}/person/"?
How would my router into urls.py look?
Thanks!
I have a model:
from django.contrib.sites.models import Site
class Person(models.Model):
site = ForeignKey(Site, on_delete=models.CASCADE)
I have two serializers:
from .models import Person
from django.contrib.sites.models import Site
class PersonSerializer(serializers.ModelSerializer):
class Meta:
fields = '__all__'
model = Person
class SiteSerializer(serializers.ModelSerializer):
class Meta:
fields = '__all__'
model = Site
I have a model view set
from .serializers import PersonSerializer
class PersonViewSet(viewset.ModelViewSet):
pass
How I would do to get all person that have a associate site from this url
"/api/site/{site_id}/person/"?
How would my router into urls.py look?
Thanks!
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.