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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:45:57+00:00 2026-06-13T04:45:57+00:00

I’ve encountered a problem with generating reverse url in templates in django. I’m trying

  • 0

I’ve encountered a problem with generating reverse url in templates in django. I’m trying to solve it since a few hours and I have no idea what the problem might be. URL reversing works great in models and views:

# like this in models.py
@models.permalink
    def get_absolute_url(self):
        return ('entry', (), {
            'entry_id': self.entry.id,
        })

# or this in views.py
return HttpResponseRedirect(reverse('entry',args=(entry_id,)))

but when I’m trying to make it in template I get such an error:

NoReverseMatch at /entry/1/
Reverse for ”add_comment” with arguments ‘(1L,)’ and keyword arguments ‘{}’ not found.

My file structure looks like this:

project/
├── frontend
│   ├── models.py
│   ├── urls.py
│   └── views.py
├── settings.py
├── templates
│   ├── add_comment.html
│   └── entry.html
├── utils
│   └── with_template.py
└── wsgi.py

My urls.py:

from project.frontend.views import *
from django.conf.urls import patterns, include, url

urlpatterns = patterns('project.frontend.views',

    url(r'^entry/(?P<entry_id>\d+)/', 'entry', name="entry"),
    (r'^entry_list/', 'entry_list'),

Then entry_list.html:

{% extends "base.html" %}
{% block content %}
    {% for entry in entries %}
            {% url 'entry' entry.id %}
    {% endfor %}
{% endblock %}

In views.py I have:

@with_template
def entry(request, entry_id):
    entry = Entry.objects.get(id=entry_id)
    entry.comments = entry.get_comments()
    return locals()

where with_template is following decorator(but I don’t think this is a case):

class TheWrapper(object):
    def __init__(self, default_template_name):
        self.default_template_name = default_template_name

    def __call__(self, func):
        def decorated_func(request, *args, **kwargs):
            extra_context = kwargs.pop('extra_context', {})
            dictionary = {}
            ret = func(request, *args, **kwargs)
            if isinstance(ret, HttpResponse):
                return ret
            dictionary.update(ret)
            dictionary.update(extra_context)
            return render_to_response(dictionary.get('template_name',
                                                     self.default_template_name),
                                      context_instance=RequestContext(request),
                                      dictionary=dictionary)
        update_wrapper(decorated_func, func)
        return decorated_func

if not callable(arg):
    return TheWrapper(arg)
else:
    default_template_name = ''.join([ arg.__name__, '.html'])
    return TheWrapper(default_template_name)(arg)

Do you have any idea, what may cause the problem?
Great thanks in advance!


EDIT:
I’ve just made an experiment. I commented everything I could leaving only:
urls.py

# -*- coding: UTF-8 -*-
from justmetyou.frontend.views import *
from django.conf.urls import patterns, include, url
urlpatterns = patterns('justmetyou.frontend.views',
    url(r'^entry/(?P<entry_id>\d+)/', 'entry', name="entry"),
)

views.py

# -*- coding: UTF-8 -*-
from justmetyou.frontend.models import *
from django.shortcuts import render_to_response, get_object_or_404
def entry(request, entry_id):
    entry = Entry.objects.get(id=entry_id)
    return render_to_response('entry.html', {'entry':entry})

entry.html

{% extends "base.html" %}
{% block content %}
{% url 'entry' 1 %}
{% endblock %}

And nothing changed. I’m getting the same error all the time.
So now I’m much more confused, because in this simple code everything looks fine. Do you think it is possible that it’s a matter of external stuff like server or smth like this…? I don’t have any idea…

  • 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-13T04:45:58+00:00Added an answer on June 13, 2026 at 4:45 am

    I suspect you are using Django 1.3 and you didn’t call {% load url from future %}.

    So try instead without ' around the name of the URL:

    {% url entry 1 %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

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.