似乎您的模板中不需要任何参数{% url %}
。
You can add function to your views.py
for creating questions, that will redirect user to question page after success:
urls.py:
url(r'^neues_thema/', 'home.views.create_question', name="create_question"),
url(r'^neues_thema/(?P<title>\w+)/', 'home.views.question', name="question"),
views.py:
from django.core.urlresolvers import reverse
from django.shortcuts import render
def create_question(request):
if request.method == 'POST':
title = request.POST['title']
# some validation of title
# create new question with title
return redirect(reverse('question', kwargs={'title': title})
def question(request, title):
# here smth like:
# question = get_object_or_404(Question, title=title)
return render(request, 'question.html', {'question': question})
template with form for creating question:
<form action="{% url create_question %}" method="post">
Answering your "what am i doing wrong?". You are trying to render url by mask neues_thema/(\w+)/
with this: {% url create_question %}
. Your mask needs some parameter ((\w+)
), but you are putting no parameter. Rendering with parameter should be {% url create_question title %}
. But the problem is: you don't know the title
while rendering page.