フィルタリングに使用しているいくつかのURLがあります。私は特定のURLを使用して値を検索すると、私は、使用されている値の多くは、言葉わたってるしきスペースを持つことになりますフィルタリングするURLから空白を削除するdjango tastypie
api/v1/labels/?brand_city__location__state_or_country=New%20York
api/v1/labels/?brand_city__city=Novi%20Sad
を取得します。どのように私はURLをスペースから%20
を削除して持つことができます返すようにきれいに:理想の
:api/v1/labels/?brand_city__city=Novi Sad
なし%20
存在
api.py
class LocationResource(ModelResource):
class Meta:
filtering = {
"state_or_country": ALL
}
class CityResource(ModelResource):
location = fields.ForeignKey(LocationResource, 'location', full=True)
class Meta:
filtering = {
"city": ALL,
"location": ALL_WITH_RELATIONS
}
class LabelResource(ModelResource):
brand_city = fields.ForeignKey(CityResource, 'brand_city', full=True)
class Meta:
filtering = {
"brand_category": ALL,
"brand_city": ALL_WITH_RELATIONS
}
スニペット応答
{
"labels": [
{
"brand_city": {
"city": "Manhattan",
"location": {
"location_choices": "State",
"state_or_country": "New York"
}
}
}
],
"meta": {
"limit": 6,
"next": null,
"offset": 0,
"previous": null,
"total_count": 1
}
}