Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Seems like you don't need any parameters to <code>{% url %}</code> in your template.</p> <p>You can add function to your <code>views.py</code> for creating questions, that will redirect user to question page after success:</p> <p><strong>urls.py:</strong></p> <pre><code>url(r'^neues_thema/', 'home.views.create_question', name="create_question"), url(r'^neues_thema/(?P&lt;title&gt;\w+)/', 'home.views.question', name="question"), </code></pre> <p><strong>views.py:</strong></p> <pre><code>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}) </code></pre> <p>template with form for creating question:</p> <pre><code>&lt;form action="{% url create_question %}" method="post"&gt; </code></pre> <hr> <p>Answering your "what am i doing wrong?". You are trying to render url by mask <code>neues_thema/(\w+)/</code> with this: <code>{% url create_question %}</code>. Your mask needs some parameter (<code>(\w+)</code>), but you are putting no parameter. Rendering with parameter should be <code>{% url create_question title %}</code>. But the problem is: you don't know the <code>title</code> while rendering page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload