how to: creating a view and serializer for adding, editing, and deleting objects with foreign relationships django rest framework
问题 I am having a very hard time connecting all the documentation on django and django rest framework on how to create a view and serializer that allows for a foreign key. edit: I might have an answer here: http://www.django-rest-framework.org/api-guide/relations/#writable-nested-serializers Example I have these models. class SearchCity(models.Model): city = models.CharField(max_length=200) class SearchNeighborhood(models.Model): city = models.ForeignKey(SearchCity, on_delete=models.CASCADE)