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 7538511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:08:21+00:00 2026-05-30T07:08:21+00:00

I know this is an easy question, I am just not getting something…so thank

  • 0

I know this is an easy question, I am just not getting something…so thank you for your patience and advice.

I have a view that asks a user to register to use our app. The data he/she submits is stored in a database and he is sent off to another page to set up the application:

#views.py

def regPage(request, id=None):
    form = RegForm(request.POST or None,
                       instance=id and UserRegistration.objects.get(id=id))

    # Save new/edited pick
    if request.method == 'POST' and form.is_valid():
        form.save()
        return HttpResponseRedirect('/dev/leaguepage/')
    user_info = UserRegistration.objects.all()
    context = {
        'form':form,
        'user_info' :user_info,
    }

    return render(request, 'regpage.html', context)

Rather than sending ALL users to the same page ‘/dev/leaguepage/’, I need to send each user to his own page based on the PK in the database like: ‘/dev/PrimaryKey/’ I am not sure how to make this happen either on the views file or in the URLs.py file:

#urls.py

from django.conf.urls.defaults import patterns, include, url
from acme.dc_django import views

urlpatterns = patterns('',

    url(r'^leaguepage/$','acme.dc_django.views.leaguePage'),




    url(r'^$', 'acme.dc_django.views.regPage'),
)

Thank you for your help!

dp

Updated code:

#url
  url(r'^user/(?P<id>\d+)/$','acme.dc_django.views.leaguePage', name="league_page"),

#view
  def regPage(request, id):
    form = RegForm(request.POST)

    # Save new/edited pick
    if request.method == 'POST' and form.is_valid():
        form.save()
        return HttpResponseRedirect(reverse('league_page', kwargs={'id' :id}))
        #return HttpResponseRedirect('/dev/leaguepage/')
    user_info = UserRegistration.objects.all()
    context = {
        'form':form,
        'user_info' :user_info,
    }

    return render(request, 'regpage.html', context)
  • 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-30T07:08:23+00:00Added an answer on May 30, 2026 at 7:08 am

    You can do a reverse lookup on your leaguePage to do your redirect, passing in the values you need to resolve the pattern. You’ll need to add a name to the URL pattern you want to reverse, but basically the syntax is:

    return HttpResponseRedirect(reverse('my_detail', args=(), kwargs={'id' : id}))
    

    Example URL pattern and view:

    urlpatterns = patterns('my_app.views',
        url(r'^my-pattern/(?P<id>\d+)/$', 'my_action', name='my_detail'),
    )
    
    def my_action(request, id):
        #do something
    

    Hope that helps you out.

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

Sidebar

Related Questions

I know this is an easy question but I can't figure it out or
I know this might be very easy to some,, I have a simple string
This should be easy, just curious. I know httpd is the HTTP daemon, just
I'm sure this is a very obvious question but I'm not getting anywhere with
First, I know this is kind of common question, but I could not find
This is an easy question but I am not sure the correct jargon to
This might be an easy question, but I'd like your help with this. I
I know this is quite easy trigonomety, however I was never introducted to vectors
I know this looks embarrassingly easy, and I guess the problem is that I
I know this is probably super easy, but I'm having a hard time wading

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.