私はこのようなモデルを得ました:
from django.db import models
from django_countries.fields import CountryField
class Location(models.Model):
company = models.CharField(max_length=64)
country = CountryField()
def __unicode__(self):
return self.company
現在、API に TastyPie を使用しています。このような非常に単純なモデルを取得しました (以前にフィルターとフィールドで編集したことがありますが、成功しませんでした)。
class LocationResource(ModelResource):
class Meta:
queryset = Location.objects.all()
resource_name = 'location'
返されるもの:
{"company": "testcompany", "country":"DE" "resource_uri": "/api/location/1/"}
私が必要とするのは、国名、またはさらに良いことに、国フィールドからのものです。