mirror of
https://github.com/nikdoof/vapemap.git
synced 2025-12-13 06:22:16 +00:00
19 lines
546 B
Python
19 lines
546 B
Python
from django.forms.models import model_to_dict
|
|
from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS
|
|
from stores.models import County, Country
|
|
|
|
|
|
class CountryResource(ModelResource):
|
|
|
|
def dehydrate(self, bundle):
|
|
counties = County.objects.filter(country=bundle.data['id'])
|
|
bundle.data['counties'] = [model_to_dict(c) for c in counties]
|
|
return bundle
|
|
|
|
class Meta:
|
|
queryset = Country.objects.all()
|
|
resource_name = 'country'
|
|
filtering = {
|
|
'id': ('exact',)
|
|
}
|