I want to parse an integer to the url so I build my urls like this(there are 3 url because can have no arguments, the place or the place and an integer)
urlpatterns = [
url(r'^map/$', geov.map_view, name = "map_view"),
url(r'^map/(?P<search_place>[^\.]+)/$', geov.map_view, name = "map_view_accurate"),
url(r'^map/(?P<search_place>[^\.]+)/(?P<digit>\d+)/$', geov.map_view),
]
So in my views I have:
def map_view(request, search_place = None, digit = 0):
results = {}
print(digit)
if search_place is not None:
query = Place_search.objects.filter(name_lower__icontains=search_place.lower()).order_by("-importance")
results["query"] = query
else:
points = Place.objects.all()
lon = points.count()
results["points"]=points
results["lon"] = lon
return render_to_response("index.html", results)
But digit is always 0 and the query variable get no elements. If I just go with the second url(Ex:"localhost:8000/map/madrid" it works correctly)