NoReverseMatch at - Reverse with arguments '('',)' not found

44 views
Skip to first unread message

Ivan Martić

unread,
Feb 4, 2019, 11:47:56 AM2/4/19
to Django users
Hi all,

I need help.
I keep getting this issue, NoReverseMatch at /

Reverse for 'productsgrouping-update' with arguments '('',)' not found. 1 pattern(s) tried: ['update/(?P<url_id>[0-9]+)/$']


not sure what am doing wrong. Any time I put url tag {% url 'productsgrouping-update' lista.id%} in html i get the error.
Both url work as stand alone, /index and /index/update/1/ but when i put url tag all hell break loose.. I strugling for a week now. Thank you all in advance.

<view>
from django.shortcuts import render, redirect
from django.http import HttpResponse
from .models import Material4, MaterialGroup
from django.db import connection
from .forms import ProductgroupinputForm, MaterialGroupForm
from django.conf import settings

def productsView(request):
lista = MaterialGroup.objects.all()
#text5 = MaterialGroup.objects.get(id=url_id)
#return redirect(reverse('productsgrouping_update', kwargs=('id':url_id)))
return render(request, "productsgroup.html", {"lista" : lista})

def productsUpdateView(request, url_id):
text5 = MaterialGroup.objects.get(id=url_id)
form5 = ProductgroupinputForm(request.POST or None, instance=text5)

context1 = {'text5': text5,'form5': form5}

if form5.is_valid():
form5.save()
return render(request, 'productsgroup-update.html', context1)

<url>
from django.urls import path
from . import views

urlpatterns = [
    path('', views.productsView, name='productsgrouping'),
    path('update/<int:url_id>/', views.productsUpdateView, name='productsgrouping-update'),
]

<main url>
from django.contrib import admin
from django.urls import path, include
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('product.urls')),
]


<model>
from __future__ import unicode_literals
from django.db import models, connection
from django.utils import timezone
from datetime import date
from django.urls import reverse

class Material4(models.Model):
    id = models.IntegerField(db_column='ID', primary_key=True, blank=False, unique=True)
    bukrs = models.CharField(db_column='BUKRS', max_length=3)
    materialid = models.CharField(db_column='MaterialID', max_length=50)
    maktx = models.CharField(db_column='MAKTX', max_length=150)
    input_group = models.IntegerField(db_column='Input_group')

    class Meta:
        managed = False
        db_table = 'Material4'

    def __str__(self):
    return '%s %s %s %s' % (self.id, self.materialid, self.maktx, self.input_group)


<forms>
from django import forms
from .models import Material4, MaterialGroup

class ProductgroupinputForm(forms.ModelForm):

    class Meta:
        model = Material4
        fields = ['materialid', 'input_group', 'id', 'input_group']

class MaterialGroupForm(forms.ModelForm):

    class Meta:
        model = MaterialGroup
        fields = ['material_group', 'id']


B.navya spoorthi Sweety

unread,
Feb 4, 2019, 5:59:09 PM2/4/19
to django...@googlegroups.com
hi all , 
i just started with django. i am following this document
here database used is sqlite. but i want to try out  django+mongodb
what all changes i can made so that django uses mongodb database 
where should i create database and use with django.

i knew Regular Mongo Db operations 

but not able to do from Django 



thanks in advance.
waiting for a reply

--
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...@googlegroups.com.
To post to this group, send email to django...@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/0f15b6d9-4dec-4ef9-b79a-643fc37a8781%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ivan Martić

unread,
Feb 8, 2019, 7:29:53 AM2/8/19
to Django users
Problem solved, I had a null value in the db so listing couldnt work..
Reply all
Reply to author
Forward
0 new messages