Tuesday, January 29, 2019

Re: NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

nvironment:


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 0
Reverse for 'update_productsgrouping' with arguments '('',)' not found. 1 pattern(s) tried: ['productsgrouping/update/(?P<url_id>[0-9]+)/$']
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=device-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">


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\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)

File "C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)

File "C:\Users\martici\qif\qif\productsgrouping\views.py" in productsgrouping_view
33. 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 'update_productsgrouping' with arguments '('',)' not found. 1 pattern(s) tried: ['productsgrouping/update/(?P<url_id>[0-9]+)/$']
napravio sam točno kako si rekao i dalje nece, isti error ...vec danima se mucim sa ovime..nešto drugo je posrijedi.





uto, 29. sij 2019. u 12:16 Nebojsa Hajdukovic <nebojsa.zerobet@gmail.com> napisao je:
neće raditi ali ne zbog html već zbog greške u views
probaj ovako 
def productsgrouping_update_view(request, url_id):  	assigned = get_object_or_404(Material, pk=url_id)

naravno prvo moraš da importuješ get object or 404:
from django.shortcuts import get_object_or_404

уто, 29. јан 2019. у 12:00 Ivan Martić <martic.ivan@gmail.com> је написао/ла:
Bok Nebojša,

mislim da je stvar u HTML možda prije, jer mi je ranije sve radilo..u jednom trenu je puknula veza. Neznam točno kada.
Znači, da odem na url productsgrouping prikaze sve grupe, kad kliknem na grupu (dodam joj a=href) no reverse mathc, ako maknem atribute u url dobijem #, a ako ručno upišem productsgrouping/update/1 onda prikaze i nastavi sve kako treba.
Znaci samo nemogu povezati ta dva linka....pogledaj htmlove u privitku

hvala ti za pomoć


uto, 29. sij 2019. u 11:35 Nebojsa Hajdukovic <nebojsa.zerobet@gmail.com> napisao je:
A što ne uradiš update preko class based view daleko je lakše?

Ako hoćeš preko funkcije ja radim sa get_object_or_404, ovako:
def productsgrouping_update_view(request, url_id):
product_lista = get_object_or_404(MaterialGroup, pk=url_id)


уто, 29. јан 2019. у 10:20 Ivan Martić <martic.ivan@gmail.com> је написао/ла:
not sure what to say

čet, 24. sij 2019. u 13:53 Ivan Martić <martic.ivan@gmail.com> napisao je:
Hi  Andréas,
sorry for misspeling in codes. All is working ok except when i try to put url tag for 'update_productsgrouping'. 
I need to update group with new products but It does not argument for group id.
What do you think i am doing wrong...?

čet, 24. sij 2019. u 13:43 Andréas Kühne <andreas.kuhne@hypercode.se> napisao je:
Hi, 

The reason you are getting this is that you are adding an argument to the productsgrouping url - which doesn't take any arguments. 

In your code you have: 
<a href="{% url 'productsgrouping' item.id%}"></a>
(Which by the way isn't correct either, I think you mean: <a href="{% url 'productsgrouping' item.id%}">{{ item }} - {{item.id}} </a>)

If you look at the url for the producsgrouping view, you have:
path('', views.productsgrouping_view, name='productsgrouping'),

Which doesn't take any arguments, when you then add an argument django can't find the right URL.

You may mean: 
<a href="{% url 'update_productsgrouping' item.id%}">{{ item }} - {{item.id}} </a>
?

Regards,

Andréas


Den tors 24 jan. 2019 kl 13:28 skrev Ivan Martić <martic.ivan@gmail.com>:
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+unsubscribe@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.

--
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+unsubscribe@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/CAK4qSCcnxCFkss1b8sOTDW3Kb6Vc1fFst4MO024%2BEq%3DwXLGjcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@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/CAFab_C8HUsxdpqz-MGqcpw0ZwgFOvrYZ-RJte6-H5x38b97ciQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@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/CAJ60hW3aGwHHutJiXASPkmgDKtn1g1QBgU4PpcuKa1zodypfRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@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/CAFab_C8ZxPMgVB6Z%3DXZ3OxNa8wQmvfmCtsvDKaxifmXHV1eZhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@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/CAJ60hW3HSn_PcNNHihst69x37QAqh1KO_pYFAusUvF-j6C9DvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@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/CAFab_C9woh%3D05E3EpBzOpfkdXT-nas427zqr8MLsDpLn0cYcFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment