Hi all,

i am having issue with url tag, every time i put url tag like --{% url 
'productsgrouping' item.id%}-- i get no reverse error.
Can you help me figure it out on what am i doing wrong?

view:
def productsgrouping_view(request):
queryset = MaterialGroup.objects.all()
context = {"list" : queryset}
return render(request, 'qif/productsgrouping/productsgroup.html', context)

def productsgrouping_update_view(request, url_id):
product_lista = MaterialGroup.objects.get(id=url_id)
product_url_id = ProductgroupinputForm(request.POST or None, 
instance=product_lista)
context1 = {'product_url_id': product_url_id, 'product_lista': 
product_lista}

if product_url_id.is_valid():
product_url_id.save()

return render(request, 'productsgroup-update.html', context1)

url:
urlpatterns = [
    path('', views.productsgrouping_view, name='productsgrouping'),
    path('update/<int:url_id>/', views.productsgrouping_update_view, 
name='update_productsgrouping'),
    path('new/', views.creategroup_view, name='create_group'),
]

html:
{% extends 'base.html' %}
{% block content %}
<ul >
{% for item in list %}
<h1>
<a href="{% url 'productsgrouping' item.id%}"></a>
{{ item }} - {{item.id}}  
</h1> 
{% endfor %}
{% endblock %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ca1ef95d-166a-40ef-91bc-16f2d704f2ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Environment:


Request Method: GET
Request URL: http://localhost:8000/productsgrouping/

Django Version: 2.1.4
Python Version: 3.7.1
Installed Applications:
['main',
 'abcclass',
 'performance',
 'productsgrouping',
 'vendorsgrouping',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'crispy_forms',
 'multiselectfield',
 'sortedm2m',
 'simple_history']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'simple_history.middleware.HistoryRequestMiddleware']


Template error:
In template C:\Users\martici\QIF\qif\templates\qif\base.html, error at line 8
   Reverse for 'productsgrouping' with arguments '('1',)' not found. 1 
pattern(s) tried: ['productsgrouping/$']
   1 : {% load staticfiles %}
   2 : 
   3 : 
   4 : <!doctype html>
   5 : <html lang="en">
   6 :   <head>
   7 :     <meta charset="utf-8">
   8 :     <meta  name="viewport" content="width=devi ce-width, 
initial-scale=1, shrink-to-fit=no">
   9 :     <meta name="description" content="">
   10 :     <meta name="author" content="Mark Otto, Jacob Thornton, and 
Bootstrap contributors">
   11 :     <meta name="generator" content="Jekyll v3.8.5">
   12 :     <title>Carousel Template · Bootstrap</title>
   13 : 
   14 :     <!-- Bootstrap core CSS -->
   15 : <link href="{% static 'css/main2.css' %}" rel="stylesheet">
   16 : 
   17 : 
   18 :     <style>


Traceback:

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py"
 in inner
  34.             response = get_response(request)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py"
 in _get_response
  126.                 response = self.process_exception_by_middleware(e, 
request)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py"
 in _get_response
  124.                 response = wrapped_callback(request, *callback_args, 
**callback_kwargs)

File "C:\Users\martici\QIF\qif\productsgrouping\views.py" in 
productsgrouping_view
  46.   return render(request, 'qif/productsgrouping/productsgroup.html', 
context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\shortcuts.py"
 in render
  36.     content = loader.render_to_string(template_name, context, request, 
using=using)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader.py"
 in render_to_string
  62.     return template.render(context, request)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\backends\django.py"
 in render
  61.             return self.template.render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in render
  171.                     return self._render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in _render
  163.         return self.nodelist.render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in render
  937.                 bit = node.render_annotated(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in render_annotated
  904.             return self.render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader_tags.py"
 in render
  150.             return compiled_parent._render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in _render
  163.         return self.nodelist.render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in render
  937.                 bit = node.render_annotated(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in render_annotated
  904.             return self.render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader_tags.py"
 in render
  62.                 result = block.nodelist.render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in render
  937.                 bit = node.render_annotated(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in render_annotated
  904.             return self.render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\defaulttags.py"
 in render
  209.                     nodelist.append(node.render_annotated(context))

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py"
 in render_annotated
  904.             return self.render(context)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\defaulttags.py"
 in render
  442.             url = reverse(view_name, args=args, kwargs=kwargs, 
current_app=current_app)

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\urls\base.py"
 in reverse
  90.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, 
**kwargs))

File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\urls\resolvers.py"
 in _reverse_with_prefix
  622.         raise NoReverseMatch(msg)

Exception Type: NoReverseMatch at /productsgrouping/
Exception Value: Reverse for 'productsgrouping' with arguments '('1',)' not 
found. 1 pattern(s) tried: ['productsgrouping/$']

Reply via email to