when user click make thumbnailbutton ,it will call def thumbin the view
and then render to http://127.0.0.1:8000/upload/thumb
I want to change to redirect to the url with the id number in database(Item.objects.all()) like :
http://127.0.0.1:8000/upload/thumb/123
But not get it. Please help me.Thank you very much.
My code:
urls.py
urlpatterns = patterns('',
url(r'^$', views.background, name='background'),
url(r'^thumb/(?P<result>\d+)$', views.thumb, name='thumb'),
views.py
def thumb(request,result):
if request.method=="POST":
photoid = request.POST['photoid']
photowidth = request.POST['photowidth']
item=Item.objects.filter(id=photoid)
return redirect(reverse('imageupload:thumb',kwargs={'result':photoid,'item':item }))
return HttpResponseRedirect(reverse('imageupload:background'))
templates:
<form action="{% url 'imageupload:thumb' i.id %}" method="POST" id="create_post">