NoReverseMatch at /Laptops/LenovoLaptops/

You answered this question yourself about 4 replies up.

Is this what you mean

<div class="Button_Panel">
     <a href="{% url 'LaptopApp:Lenovo_Laptop_Details' Lenovo_Laptop_List.Model_Name 
     %}" class="button"> Details </a>
     {{Lenovo_Laptop_List.Model_Name}}
 </div>

That’s not what you said, but that would work too if that’s what you want.

That didn’t worked and I am not getting your point.
Can we have a zoom meeting if you don’t mind.

I’m sorry, I don’t provide private support.

This may not be the only problem involved, but it’s the first that I’ve identified. If you’re still having the same error, please post the complete traceback and error message. If the message has changed, please provide the message associated with the new error.

No message didn’t changed.
It’s still giving me the same error.

Internal Server Error: /Laptops/LenovoLaptops/
Traceback (most recent call last):
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\core\handlers\exception.py”, line 55, in inner
response = get_response(request)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\core\handlers\base.py”, line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “E:\Django_Main_Project\digital_world\LaptopApp\views.py”, line 25, in LenovoLaptopListView
return render (request, ‘LaptopApp/Lenovo_Laptop.html’, context={‘Lenovo_dictionary’:Lenovo_dictionary, ‘Lenovo_Product_Count’:Lenovo_Product_Count})
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\shortcuts.py”, line 24, in render
content = loader.render_to_string(template_name, context, request, using=using)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\loader.py”, line 62, in render_to_string
return template.render(context, request)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\backends\django.py”, line 62, in render
return self.template.render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 175, in render
return self._render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 167, in _render
return self.nodelist.render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\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\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 1000, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 958, in render_annotated
return self.render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\loader_tags.py”, line 157, in render
return compiled_parent._render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 167, in _render
return self.nodelist.render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\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\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 1000, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 958, in render_annotated
return self.render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\loader_tags.py”, line 63, in render
result = block.nodelist.render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\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\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 1000, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 958, in render_annotated
return self.render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\defaulttags.py”, line 238, in render
nodelist.append(node.render_annotated(context))
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\template\base.py”, line 958, in render_annotated
return self.render(context)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\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\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\urls\base.py”, line 88, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
File “C:\Users\Anish.virtualenvs\digital_world-REi3i3Fm\lib\site-packages\django\urls\resolvers.py”, line 802, in _reverse_with_prefix
raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for ‘Lenovo_Laptop_Details’ with arguments ‘(‘ThinkPad X1 Core i7 10th Gen(16 GB/512 GB)’,)’ not found. 1 pattern(s) tried: [‘Laptops/LenovoLaptops/(?P<Model_Name>[^/]+)/\Z’]
[13/Mar/2023 23:05:55] “GET /Laptops/LenovoLaptops/ HTTP/1.1” 500 190326

For the purposes of trying to identify the issue here, replace the <a>..</a> tag with:
<hr>--- {{Lenovo_Laptop_List.Model_Name}} ---<hr>
Then report what shows up between the “—” characters in the page.

This will help verify that what you’re expecting to see at that point is what you’re expecting to see.

Ok, I see the problem. That character string is a horrible thing to try and use as a url parameter. You will need to urlencode that string to make it usable in this case.

(What I’d really suggest you do is use the PK of the appropriate table instead of trying to use the text name of the device.)

Only <a> tag will be replaced with the <hr>. Rest all contents will be same ?

No need at this point - the detailed error message cleared up the situation. See my previous reply.

It worked, but why with strings it was giving me problem ? I don’t understand it. For MobileApp it worked completely fine . Shall I change there also from string to int .

It would be a case-by-case situation. It will work with some names, not with some others.

But yes, you either want to use the numerical pk as the url or possibly a slug. But raw text without being “sanitized” is problematic.

Thank you very much for the help.
I will do the necessary change in MobileApp also.
So that in future I won’t face such problem .

Thank You very much.