Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7000411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:40:02+00:00 2026-05-27T20:40:02+00:00

I am trying to pass the id through reverse. But it’s not working. I’m

  • 0

I am trying to pass the id through reverse. But it’s not working. I’m getting this error

Reverse for ‘reg.views.thanks’ with arguments ‘(20,)’ and keyword arguments ‘{}’ not found.

Here is my views.py:

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})

Here is my urls.py:

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'}),
)

Here is thanks.html:

<html>
<body>
<p>Thank you for registration mr.{{reg.username}}</p>
</body>
</html>

and I’m also showing my models.py:

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

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:40:03+00:00Added an answer on May 27, 2026 at 8:40 pm

    This line

    return HttpResponseRedirect(reverse('reg.views.thanks', args=(id,)))
    

    Is trying to construct a url to your view reg.views.thanks, with the id variable used as a parameter.

    This line in urls.py

    url(r'^thanks/$', 'reg.views.thanks'),
    

    Does not have anywhere for that parameter to go.

    The first thing that you need to figure out is whether you actually want to send an HTTP redirect to the browser to tell it to go to the ‘thanks’ page. If you really do, then you need a way to send that id in the URL. You can do it as part of the URL path itself, as @moguzalp suggests, or you can put it in the query string, like

    /thanks/?id=12345
    

    Or you can do other things, like stashing the id in the user’s session, and pulling it out when they request the thanks page. That’s a bit more complicated, though.

    If you don’t actually need to issue an HTTP redirect, then there’s nothing stopping you from just calling the thanks() function from inside your view function, like this:

    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))
    

    The URL won’t change in the browser, but the correct ID will be used, and doesn’t need to appear anywhere else, in the URL, the query parameters, or the session

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass through POST an array of checkboxes but this time it's
I'm trying to pass a variable through a ssh connection, like this: working_dir=/home/user/some_dir/ ssh
I'm trying to pass this to a PHP script through AJAX: var answers={}; for
I'm getting the following exception trying to pass an object through wcf: There was
I'm trying to pass through several functions a string with a path but the
Currently I am trying to pass some values through command line arguments and then
I'm trying to pass big strings of random html through regular expressions and my
I'm trying to pass big strings of random html through regular expressions and my
I'm trying to pass a JavaScript object to a PHP script through jquery.ajax() ,
I'm currently trying to pass a mono threaded program to multithread. This software do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.