My view :
def display(request):
feed = SoukFeedMaster.objects.filter(person = request.user)
return render(request, 'soukfeed/display.html', {'feed' : feed ,})
My Template :
{% extends "base.html" %}
{% block content %}
{% for x in feed %}
{% load url from future %}
<a href="{% url x.content.url_internal_django_link x.content.id %}"> {{x.content.content}} </a>
<br/>
{% endfor %}
{% endblock %}
Traceback :
Environment:
Request Method: GET
Request URL: http://localhost:8000/soukfeed/
Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.comments',
'ec.kiosk',
'ec.chakra',
'ec.ajax',
'ec.broadcast',
'ec.connect',
'ec.seek_solutions',
'ec.feed',
'ec.ec_model',
'ec.info',
'ec.souk_info',
'ec.ec_central',
'ec.domains',
'ec.souk',
'ec.souk_feed',
'ec.meta',
'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Template error:
In template /volumes/disk2/workspace/templates/ec/soukfeed/display.html, error at line 1
Caught NoReverseMatch while rendering: Reverse for '' with arguments '(1,)' and keyword arguments '{}' not found.
1 : {% extends "base.html" %}
{% block content %}
{% for x in feed %}
{% load url from future %}
<a href="{% url x.content.url_internal_django_link x.content.id %}"> {{ x.content.content }} </a>
<br/>
{% endfor %}
{% endblock %}
Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/Volumes/Disk2/workspace/ec/ec/souk_feed/views.py" in display
18. return render(request, 'soukfeed/display.html', {'feed' : feed ,})
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render
44. return HttpResponse(loader.render_to_string(*args, **kwargs),
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
188. return t.render(context_instance)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/base.py" in render
123. return self._render(context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/loader_tags.py" in render
127. return compiled_parent._render(context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/loader_tags.py" in render
64. result = block.nodelist.render(context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/defaulttags.py" in render
227. nodelist.append(node.render(context))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/defaulttags.py" in render
450. raise e
Exception Type: TemplateSyntaxError at /soukfeed/
Exception Value: Caught NoReverseMatch while rendering: Reverse for '' with arguments '(1,)' and keyword arguments '{}' not found.
NoReverseMatch (source code) is a Django exception that is raised when a URL cannot be matched against any string or regular express in your URL configuration. A URL matching problem is often caused by missing arguments or supplying too many arguments.
Make sure you are passing the correct number of Arguments or Keyword arguments in URL template tag. As you can see in urls.py file, URL with name 'news-year-archive ' expects an argument 'year' in it. If you are not passing the year in url template tag, application will throw the error.
reverse() If you need to use something similar to the url template tag in your code, Django provides the following function: reverse (viewname, urlconf=None, args=None, kwargs=None, current_app=None)
The NoReverseMatch error is saying that Django cannot find a matching url pattern for the url you've provided in any of your installed app's urls. The NoReverseMatch exception is raised by django. core. urlresolvers when a matching URL in your URLconf cannot be identified based on the parameters supplied.
Just had the same problem with my app. The following solved it for me:
Because you’re using the {% url %}
tag to generate the link to the view, you need to add the URLs for the application to your project’s root URLConf module (via include() calls). If you use the {% url %}
tag with a URL name that you haven’t yet set up in your project, it won’t be able to find the correct URL and will simply return an empty string instead of a URL.
So basically the problem is that the url you're looking up must be in the urls.py of your project, otherwise Django can't find and trace it.
It is really not enought information. But the problem is here:
{% url x.content.url_internal_django_link x.content.id %}
May be you need that:
{% extends "base.html" %}
{% block content %}
{% for x in feed %}
<a href="{{ x.content.get_absolute_url }}"> {{x.content.content}} </a>
<br/>
{% endfor %}
{% endblock %}
But I am not sure - it depends from you model code and your general logic
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With