Ich habe ein paar URLs, die ich zum Filtern verwenden. Wenn ich für Werte suchen, um die spezifischen URLs bekomme ichEntfernen von Leerzeichen aus filternd url django tastypie
api/v1/labels/?brand_city__location__state_or_country=New%20York
api/v1/labels/?brand_city__city=Novi%20Sad
Alot von Werten einen Raum dazwischen Worte müssen verwendet werden. Wie kann ich %20
aus den Räumen entfernen und die URL habe saubere zurückzukehren:
Wunsch: api/v1/labels/?brand_city__city=Novi Sad
keine %20
vorhanden
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
}
Snippet Antwort
{
"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
}
}