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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:10:34+00:00 2026-05-23T05:10:34+00:00

This subject is continuation of thinking in this topic . I fell back in

  • 0

This subject is continuation of thinking in this topic. I fell back in problem of reverse in generic views. Last time I thought it’s no reverse match because I used many to many, now I haven’t many to *** relations in reverse but problem still in there. Since I have generic view in urls in both cases, I suggested the problem is in generic views and no view function.
At first I used @permalink decorator in the models

...
@permalink
def get_absolute_url(self):
    return ('categories', str(self.id))
...
@permalink
def get_absolute_url(self):
    return ('pages', (), {'page_name': self.human_readable_url})

urls

url(r'^(?P<page_name>&\w*)?/?$', direct_to_template,
    {'template': 'basic.djhtml'},
    name = "pages"),
url(r'cat/\d+/$',
    direct_to_template,
    {'template': 'basic.djhtml'},
    name = "categories")

And got an error:

NoReverseMatch: Reverse for ‘pages’ with arguments ‘()’ and keyword arguments ‘{‘page_name’: u’page1′}’ not found.

Then I tried reverse method

def get_absolute_url(self):
    return reverse('categories', args = [self.id, ])

And have the same error

NoReverseMatch: Reverse for ‘categories’ with arguments ‘(2,)’ and keyword arguments ‘{}’ not found.

Based on the fact that permalink not explicitly use reverse method, I think that the problem is in interaction reverse and generic view in url. Why is it happens? How to use reverse in url generic views?

  • 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-23T05:10:35+00:00Added an answer on May 23, 2026 at 5:10 am

    The problem is, you have given the name categories to a generic view, direct_to_template, and you are passing an argument to that view – but direct_to_template doesn’t take that argument, only a dictionary containing extra context.

    If you want to pass additional arguments to a generic view, you can – but they will only be passed on to the Template. You can extend the view by writing your own function, which adds the parameter into a dictionary, then calls the generic view. Something like this:

    # views.py
    from django.views.generic.simple import direct_to_template
    
    def my_view(id):
        more_data = {'id': id}
        return direct_to_template(template = 'basic.djhtml', more_data)
    

    And then in your urls.py, replace the direct_to_template with my_view. Since my_view takes an id argument, reverse will properly match it, and the argument will be passed in to the generic view, and through to the template.

    Presumably somewhere in your template is a line such as, {{ id }}.

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

Sidebar

Related Questions

All the articles I Googled on this subject are dated back in 2004-2005. Basically
I have a problem finding references to this subject and would appreciate some help.
This subject, as with any optimisation problem, gets hit on a lot, but I
I know this subject has been discussed before but still have problem with refresh
This subject has been touched on before, but there's been some time since the
IMPORTANT EDIT: Back again on this subject. As you said there should be no
there is a topic about this subject which is working with arrays but I
I searched for this subject on Google and got some website about an experts
I read a few other posts on this subject and am still confused. In
I've found an article on this subject by a Microsoft employee, but has anyone

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.