After i ran a view without a template, id like to reverse back to the previous view. However this view had a dynamic part in it, and now i cant figure out how i could pas that argument with my reverse:
My urls:
url(r'^building/(?P<building_id>\d+)/$', views.building, name='building'),
url(r'^building/upgrade/(?P<building_id>\d+)/$', views.building_upgrade, name='building_upgrade'),
My view:
@login_required
def building_upgrade(request, building_id):
building = get_object_or_404(Building, pk=building_id)
if building.town.user != request.user:
return HttpResponseRedirect(reverse('index'))
create_upgrade(building)
return HttpResponseRedirect(reverse('building'))
How can i send the building_id back with the reverse, so it knows what url to load?
reverse('building', kwargs={'building_id': building_id})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With