Note that there are some explanatory texts on larger screens.

plurals
  1. POreverse() is not working
    primarykey
    data
    text
    <p>I am trying to pass the id through reverse. But it's not working. I'm getting this error</p> <p>Reverse for 'reg.views.thanks' with arguments '(20,)' and keyword arguments '{}' not found.</p> <p>Here is my views.py:</p> <pre><code>from django.http import HttpResponse, Http404, HttpResponseRedirect from django.core.urlresolvers import reverse from reg.models import registration, registrationform from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext def registration(request): if request.method == 'POST': form = registrationform(request.POST) if form.is_valid(): data = form.save() id = data.id return thanks(request,id) else: form = registrationform() return render_to_response('registration.html', {'form' : form}, context_instance=RequestContext(request)) def thanks(request, id): p = get_object_or_404(registration, pk=id) return render_to_response('thanks.html', {'reg' : p}) </code></pre> <p>Here is my urls.py:</p> <pre><code>from django.conf.urls import patterns, include, url url(r'^registration/$', 'reg.views.registration'), url(r'^thanks/$', 'reg.views.thanks'), url(r'^$','django.views.generic.simple.direct_to_template', {'template' : 'index.html'}), ) </code></pre> <p>Here is thanks.html:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;p&gt;Thank you for registration mr.{{reg.username}}&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and I'm also showing my models.py:</p> <pre><code>from django.db import models from django.forms import ModelForm class registration(models.Model): username = models.CharField(max_length=100) password = models.CharField(max_length=100) def __unicode__(self): return self.name class registrationform(ModelForm): class Meta: model = registration </code></pre> <p>Thanks.</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.
 

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