В моем приложении django я пытаюсь перенаправить в представление после того, как пользователь отправляет форму
Ошибка, которую я получаю
Reverse for 'contents-occasion-step-1' with no arguments not found. 1 pattern(s) tried: ['myapp/create/step-1/(?P<current_object_id>\\d+)$']
Функция, с которой я перенаправляю представление
def create_object(request):
if request.method == 'POST':
form = DataBase(request.POST)
if form.is_valid():
form_data = form.save(commit=False)
form_data.created_by = request.user
form_data.save()
# save current object id in the session
request.session['current_object_pk'] = form_data.pk
manipulation_function(request, form_data)
return redirect('contents-occasion-step-1', current_object_id = form_data.pk)
else:
form = DataBase()
return render(request, 'my/create_object.html', {
'form': form
})
Мои urls.py
url(r'myapp/create/step-1/(?P<current_object_id>\d+)$', views.contents_occasion_step_1, name='contents-occasion-step-1')
Мои просмотры.py
def contents_occasion_step_1(request, current_object_id):
"""View
"""
[My code below]
return render(request, 'myapp/mytemplate.html', {
'variable_for_template': request.session['variable_for_template']
})