Hey so I was having an issue with the url pulling a no reverse match every time I try and open the page and the only way the page will open is if i replace product.id in the index.html with a constant such as 1(represents the product id) I want it to be essentially a variable so for each product added to the admin panel it pulls up a new link that has descriptions for each product. I’ve tried a lot of things so my code might be a little hard to read but thank you for any help!
Error Traceback: Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/playground/
Django Version: 4.0.4
Python Version: 3.10.4
Installed Applications:
[‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘playground.apps.PlaygroundConfig’]
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’]
Template error:
In template C:\Users\Zoro\Desktop\storefront\storefront\playground\templates\products\index.html, error at line 17
Reverse for ‘information’ with arguments ‘(’‘,)’ not found. 1 pattern(s) tried: [‘playground/(?P<product_id>[0-9]+)\Z’]
7 :
8 : Work
9 : Type of Work
10 : Hours needed
11 :
12 :
13 :
14 : {% for context2 in context%}
15 :
16 :
17 : <a href= {%url ‘trog:information’ product.id%} >{{context2.work}}
18 :
19 : {{context2.genre}}
20 : {{context2.hoursWorked}}
21 :
22 : {% endfor %}
23 :
24 :
25 :
26 :
27 : {% endblock %}
Traceback (most recent call last):
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\exception.py”, line 55, in inner
response = get_response(request)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\base.py”, line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “C:\Users\Zoro\Desktop\storefront\storefront\playground\views.py”, line 11, in hello
return render(request, ‘products/index.html’, context2)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\shortcuts.py”, line 24, in render
content = loader.render_to_string(template_name, context, request, using=using)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\loader.py”, line 62, in render_to_string
return template.render(context, request)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\backends\django.py”, line 62, in render
return self.template.render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 175, in render
return self._render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 167, in _render
return self.nodelist.render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 1000, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 1000, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 958, in render_annotated
return self.render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\loader_tags.py”, line 157, in render
return compiled_parent._render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 167, in _render
return self.nodelist.render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 1000, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 1000, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 958, in render_annotated
return self.render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\loader_tags.py”, line 63, in render
result = block.nodelist.render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 1000, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 1000, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 958, in render_annotated
return self.render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\defaulttags.py”, line 238, in render
nodelist.append(node.render_annotated(context))
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\base.py”, line 958, in render_annotated
return self.render(context)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\defaulttags.py”, line 472, in render
url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\base.py”, line 88, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
File “C:\Users\Zoro\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py”, line 802, in _reverse_with_prefix
raise NoReverseMatch(msg)
Exception Type: NoReverseMatch at /playground/
Exception Value: Reverse for ‘information’ with arguments ‘(’‘,)’ not found. 1 pattern(s) tried: [‘playground/(?P<product_id>[0-9]+)\Z’]