"Environment of the project: Request Method: GET Request URL: Django Version: 3.0.5 Python Version: 3.10.7" "error is with the template and url" "eg: more details about question ....................................." "error at line 12" "Reverse for 'customer' with keyword arguments '{'pk': ''}' not found. 1 pattern(s) tried: ['customer/(?P<pk>[^/]+)/$']" 2 : 3 : <div class="homeWrapper"> 4 : <header> 5 : <nav> 6 : <ul class="nav__links"> 7 : <li><a href="{% url 'home' %}">Home</a></li> 8 : <li><a href="{% url 'gallery' %}">Gallery</a></li> 9 : <li><a href="#faqs" class="scroll">About us</a></li> 10 : <!--page is in demo mode after deployment logic will be made here-->
##error is with line 12
11 : {% if user.is_authenticated %} 12 : <li><a href=" {% url 'customer' pk=current.id %} ">Customer</a></li> 13 : {% else %} 14 : <li><a class="scroll" href="#login">Login</a></li> 15 : {% endif %} 16 : {% if request.user.is_staff %} 17 : <li><a href="{% url 'graph' %}">Dash Board</a></li> 18 : {%endif%} 19 : <script src="https://cdn.jsdelivr.net/npm/darkmode-js@1.5.7/lib/darkmode-js.min.js"></script> 20 : </ul> 21 : </nav> 22 :
#log ” Traceback (most recent call last): File “/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/exception.py”, line 34, in inner response = get_response(request) File “/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/base.py”, line 115, in _get_response response = self.process_exception_by_middleware(e, request) File “/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/base.py”, line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File “/app/website/views.py”, line 298, in gallery return render ( request, ‘gallery.html’, context) File “/app/.heroku/python/lib/python3.10/site-packages/django/shortcuts.py”, line 19, in render content = loader.render_to_string(template_name, context, request, using=using) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/loader.py”, line 62, in render_to_string return template.render(context, request) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/backends/django.py”, line 61, in render return self.template.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 171, in render return self._render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 163, in _render return self.nodelist.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 936, in render bit = node.render_annotated(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 903, in render_annotated return self.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/loader_tags.py”, line 150, in render return compiled_parent._render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 163, in _render return self.nodelist.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 936, in render bit = node.render_annotated(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 903, in render_annotated return self.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/loader_tags.py”, line 188, in render return template.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 173, in render return self._render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 163, in _render return self.nodelist.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 936, in render bit = node.render_annotated(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 903, in render_annotated return self.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/defaulttags.py”, line 309, in render return nodelist.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 936, in render bit = node.render_annotated(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/base.py”, line 903, in render_annotated return self.render(context) File “/app/.heroku/python/lib/python3.10/site-packages/django/template/defaulttags.py”, line 443, in render url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app) File “/app/.heroku/python/lib/python3.10/site-packages/django/urls/base.py”, line 87, in reverse return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)) File “/app/.heroku/python/lib/python3.10/site-packages/django/urls/resolvers.py”, line 677, in _reverse_with_prefix raise NoReverseMatch(msg)
Exception Type: NoReverseMatch at /gallery Exception Value: Reverse for 'customer' with keyword arguments '{'pk': ''}' not found. 1 pattern(s) tried: ['customer/(?P<pk>[^/]+)/$']
” [1]: https://i.stack.imgur.com/8MqOm.jpg
Advertisement
Answer
====== put like this =====
{% url 'customer' request.user.id %}