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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:25:51+00:00 2026-05-26T16:25:51+00:00

I am trying to get a url structure like this. http://example.com/blog/1/title-name-goes-here My main urls

  • 0

I am trying to get a url structure like this.

http://example.com/blog/1/title-name-goes-here

My main urls file has this line, among others.

url(r'^blog/', include('blog.urls')),

in my blog.urls I have

urlpatterns = patterns('',
    (r'', 'blog.views.index'),
    (r'^(?P<entry_id>\d+)/(?P<slug>[a-zA-Z0-9_.-]+)/$', 'blog.views.entry'),
)

My problem is when I visit /blog/1/some-title I get the index view called, not the entry view method. It also doesn’t matter what order the routes are in either.

I think the regex is wrong. I am still not good with them.

  • 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-26T16:25:51+00:00Added an answer on May 26, 2026 at 4:25 pm

    try:

    urlpatterns = patterns('',
        (r'^(?P<entry_id>\d+)/(?P<slug>[-\w]+)/$', 'blog.views.entry'),
        (r'^$', 'blog.views.index'),
    )    
    

    Notice the carat and dollar sign in the lower pattern which signifies an empty pattern. You should (generally) put your patterns in order of how many groups then need to match e.g. /id/slug/title/ above /id/slug/ above /id/ as the URLconf chooses the first match possible. You can use RegexPal to test your patterns online which is handy

    I also changed the slug to a simpler slug pattern using \w (word, number underscore – I’m not sure if you specifically want to match dots in slugs?)

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

Sidebar

Related Questions

I have a URL that is in the following structure: http://somewebsite.com/directory1/directory2/directory3 ... I'm trying
I am trying to get the requested URL from PHP. The URL is like
Please see the following link structure http://stackoverflow.com/questions/10672712/voting-system-like-stackoverflow In the above link the 10672712 is
I'm trying to parse parameters in a URL in VBA. For example: https://www.google.com/webhp?q=vba+url+parameters&utf_source=stackoverflow I'm
I am trying to do some curl'ing from PHP I have: $url=http://sites.target.com/site/en/spot/mobile_fiats_results.jsp?_DARGS=/site/en/spot/mobile_fiats.jsp&asin=&dpci=.$arriPadSKU[$counter].&zipcode=.$vZip.&city=&state=; $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,
Im using The HTML Mobile Bolierplate and im trying to get the URL Address
I am trying to get the public URL of a given file stored in
Possible Duplicate: Get URL of ASP.Net Page in code-behind I'm trying to hold current
I'm trying to get an image from URL and save it to the isolated
I am trying to get an image from URL in Android and set it

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.