get data of database with id

Hi. I have a problem in get data with press button of database.


class BnBar(models.Model):
   user_name = models.ForeignKey(Informations_Bi, on_delete=models.CASCADE, blank=True, null=True)
   gharardad = models.ForeignKey(Gharardad, on_delete=models.SET_NULL, null=True, blank=True)
   barnameid = models.SlugField(unique=True, max_length=50,  name="barnameid", null=True,         blank=True)

and this is

def Print_ListView(request, idd, slug):
   emp = get_object_or_404(BnBar, id=idd, slug=slug)
   return render(request, 'print_output.html', {'emp': emp})

and this is

urlpatterns = [
   path('ShowBn/<int:idd>/', Print_ListView, name='printviewss') ]

and I have two html file that first is for table and second is for button

this is list_of_table.html for button print detail

<a class="btn btn-info btn-sm" href="{% url   'barbari:printviewss' idd=emp.id_list %}">print</a>

problem is here.

when press print this is error:

Reverse for ‘printviewss’ with keyword arguments ‘{‘idd’: ‘’}’ not found. 1 pattern(s) tried: [‘ShowBn/(?P[0-9]+)/\Z’]


First, when posting code here, enclose the blocks of code (and template) between lines of three backtick - ` characters. That means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep the code properly formatted, which is critical with Python.

Also, you do not need to repost your code - you can edit your original post to surround each block of code with the lines of ```.

When this line is being rendered in your template, what is the value of emp.id_list?

From your view, it looks like emp is going to be an instance of BnBar, but your BnBar object doesn’t have a field named id_list.

thanks a lot.
its done