Detail View of a Object

hello everyone, i am trying to understand the logic of detail view and made a dummy project, i made it before with a tutorial but now it is not working no matter i’ve done. Here is my code:

from django.shortcuts import render
from .forms import SeçimForm
from .models import Seçim

# Create your views here.

def index(request):
    adam = Seçim.objects.all().order_by("-id")
    if request.method == "POST":
        form = SeçimForm(request.POST, request.FILES)
        if form.is_valid():
            yeni_seçim =
            yeni_seçim.user = request.user
        form = SeçimForm(data=request.GET)
    return render(request, 'selectapp/index.html',{

def detail(request, item_id):
    seçim = Seçim.objects.get(pk=item_id)
    context = {
    return render(request, 'selectapp/detail.html', context)

from django.urls import path
from selectapp import views

app_name = 'selectapp'

urlpatterns =[
    path('',views.index, name='index'),
    path('<int:item_id>/', views.detail, name='detail'),

from django.db import models
from django.urls import reverse
from django.utils.text import slugify

# Create your models here.

class Seçim(models.Model):

    def __str__(self):
        return self.user

    user = models.CharField(max_length=50, blank=False)
    adam = models.CharField(max_length=50, blank=False)

    def get_absolute_url(self):
        return reverse("selectapp:detail", kwargs={"pk"})

from django import forms
from .models import Seçim

demo_seçimler = (

class SeçimForm(forms.ModelForm):
    adam = forms.MultipleChoiceField(label="adamlar", choices = demo_seçimler, required= False)
    class Meta:
        fields = ('adam',)


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="" rel="stylesheet" />
            width: 50%;
    <form method="POST"> 
        {% csrf_token %} 
        {{ form.as_p }} 
        <input type="submit" value="Submit"> 

    {% for kişi in adam %}
    <div class="card">
       <a href="{% url 'selectapp:detail' Seç %}"> {{ kişi.adam }} </a>
    {% endfor %}

    <script src="" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
    <script src=""></script>
        $(document).ready(function() {


it is keep giving:

NoReverseMatch at /
Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P<item_id>[0-9]+)/\\Z']

thank you :slight_smile:

I think that you mispelled this variable name.

There is no Seçim in your context, so i think that you wanted to refer to the kiş variable instead:

    {% for kişi in adam %}
    <div class="card">
      <!-->The only line that changed is the below one</!-->
       <a href="{% url 'selectapp:detail' kiş %}"> {{ kişi.adam }} </a>
    {% endfor %}

1 Like

thank you so much i can’t believe i didn’t see that. i was about to give up :slight_smile: