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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:15:42+00:00 2026-06-18T02:15:42+00:00

I was going through the django tutorial and though now almost everything there seems

  • 0

I was going through the django tutorial and though now almost everything there seems pretty clear, I am having trouble understanding the regex while matching the urls :

r'^(?P<poll_id>\d+)/$

what does (?P<poll_id>\d+) do ?

I am understanding that after stripping off the "34/" from "polls/34/", The polls.url is being called and there the keyword urlpatterns is being looked for , but how does poll_id get this value 34 ?

I know only a bit of regex, so thats why it might be hard for me to read.
Also, here is the reference that I am using for this question :Tutorial Part3

  • 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-06-18T02:15:43+00:00Added an answer on June 18, 2026 at 2:15 am

    It’s a regex that takes the poll_id (a number) as a variable.

    The corresponding view is:

    def detail(request, poll_id):
        return HttpResponse("You're looking at poll %s." % poll_id)
    

    Now when you go to example.com/polls/34/, it knows you are looking for poll number 34, and it brings that in to the view as the poll_id.

    So in your view, poll_id = 34. This allows you to display or manipulate this specific poll.

    Essentially the point of the regex in this case is to allow you to view a large number of specific polls without having to create an explicit url for each one.

    To clarify, this regex is saying take any number \d+, save it as poll_id, and proceed to this view with that poll_id.

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

Sidebar

Related Questions

I'm new to django and currently going through the main tutorial. Even though it
I am going through another django tutorial and I noticed for the imports the
Hey All- I'm completely new to Django/python and am going through a tutorial for
I'm going through Django tutorial and using PyDev Eclipse plugin for development. For interactive
I am going through the following tutorial , and the models.py code seems to
I'm working through the Django tutorial after having installed the development source of Django
I'm going through a django tutorial to create a wiki and I'm a little
Here's some code in a django tutorial that I'm going through. I've never come
I'm going through the standard Django tutorial to create an admin for an app.
I'm going through the basic django tutorial and I'm running the server using python

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.