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

  • Home
  • SEARCH
  • 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 173567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:21:59+00:00 2026-05-11T13:21:59+00:00

N.B This question has been significantly edited before the first answer was given. Hi,

  • 0

N.B This question has been significantly edited before the first answer was given.

Hi,

I’m fairly new to django, so apologies if I’m missing something obvious.

I’ve got a urls.py file that looks like this:

urlpatterns = patterns(     '',     (r'^$', 'faros.lantern.views.home_page'),     (r'^login/$', 'django.contrib.auth.views.login'),     (r'^logout/$', 'django.contrib.auth.views.logout'),     (r'^about/$', 'faros.lantern.views.about_page_index', {}, 'about_page_index'),     (r'^about/(?P<page_id>([a-z0-9]+/)?)$', 'faros.lantern.views.about_page', {}, 'about_page'), ) 

Views that looks like this:

def about_page_index(request):     try:         return render_to_response('lantern/about/index.html', context_instance=RequestContext(request))     except TemplateDoesNotExist:         raise Http404  def about_page(request, page_id):     page_id = page_id.strip('/ ')      try:         return render_to_response('lantern/about/' + page_id + '.html', context_instance=RequestContext(request))     except TemplateDoesNotExist:         raise Http404 

And a template that includes this:

<a href='{% url lantern.views.about_page_index %}'>Contact</a> <a href='{% url lantern.views.about_page page_id='contact' %}'>Contact</a> 

I’m getting this error message:

Caught an exception while rendering: Reverse for '<function about_page at 0x015EE730>' with arguments '()' and keyword arguments '{'page_id': u'contact'}' not found. The first reverse works fine (about_page_index), generating the correct URL without error messages. 

I think this is because the request argument to the about_page view (request) is used, so I need to pass it in when I generate the URL in my template. Problem is, I don’t know how to get to it, and searching around isn’t getting me anywhere. Any ideas?

Thanks,

Dom

p.s. As an aside, does that method of handling static ‘about’ type pages in an app look horrific or reasonable? I’m essentially taking URLs and assuming the path to the template is whatever comes after the about/ bit. This means I can make the static pages look like part of the app, so the user can jump into the about section and then right back to where they came from. Comments/Feedback on whether this is djangoic or stupid appreciated!

  • 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. 2026-05-11T13:22:00+00:00Added an answer on May 11, 2026 at 1:22 pm

    If I guess correctly from the signature of your view function (def about_page(request, page_id = None):), you likely have another URL configuration that points to the same view but that does not take a page_id parameter. If so, the django reverse function will see only one of these, and it’s probably seeing the one without the named page_id regex pattern. This is a pretty common gotcha with reverse! 🙂

    To get around this, assign a name to each of the url patterns (see Syntax of the urlpatterns variable). In the case of your example, you’d do:

    (r'^about/(?P<page_id>([a-z]+/)?)$', 'faros.lantern.views.about_page',   {}, 'about_with_page_id') 

    and then in the template:

    <a href='{% url about_with_page_id page_id='contact' %}'>Contact</a> 

    Edit

    Thanks for posting the updated urls.py. In the url template tag, using the unqualified pattern name should do the trick (note that I’m deleting the lantern.views part:

    <a href='{% url about_page_index %}'>Contact</a> <a href='{% url about_page page_id='contact' %}'>Contact</a> 

    Edit2

    I’m sorry I didn’t twig to this earlier. Your pattern is expressed in a way that django can’t reverse, and this is what causes the mismatch. Instead of:

    r'^about/(?P<page_id>([a-z]+/)?)$' 

    use:

    r'^about/(?P<page_id>[a-z0-9]+)/$' 

    I created a dummy project on my system that matched yours, reproduced the error, and inserted this correction to success. If this doesn’t solve your problem, I’m going to eat my hat! 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 152k
  • Answers 152k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Done incorrectly there are no advantages. In this approach, one… May 12, 2026 at 10:06 am
  • Editorial Team
    Editorial Team added an answer Shortly after :help p it says: :[line]pu[t] [x] Put the… May 12, 2026 at 10:06 am
  • Editorial Team
    Editorial Team added an answer I'm not aware of any library methods that will do… May 12, 2026 at 10:06 am

Related Questions

In response to this question asking about hex to (raw) binary conversion, a comment
N.B THIS QUESTION HAS BEEN UPDATED, READ FURTHER DOWN Hi, I want to create
Let me start with a specific example of what I'm trying to do. I
What is an effective algorithm for nesting 1 dimensional lengths into predefined stock lengths?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.