I have HttpResponseRedirect()
function which constructs the required url:
my create
view:
def create(request):
entry = Char_field(field=request.POST['record'])
entry.save()
return HttpResponseRedirect(reverse('db:index_page',kwargs={'redirected':'true'}))
the view which the HttpResponseRedirect()
redirects to is:
def index(request):
redirected = False
template= 'app/index.html'
try:
if request.POST['redirected'] is 'true':
redirected = True
except:
pass
return render(request,template,{'redirected':redirected})
However it returns an error:
NoReverseMatch at /app/create/
Reverse for 'index_page' with arguments '()' and keyword arguments '{'redirected': 'true'}' not found.
urls.py:
urlpatterns = patterns('',
url(r'^$',views.index,name='index_page'),
url(r'^get_record/$',views.get_record,name='get_record'),
url(r'^create/$',views.create_html,name='create_path'),
url(r'^add/$',views.create,name='add_record')
)
Why is this so and Is it possible send POST
data to the index_page
view through the reverse()
function?