Django copy object: func with in html, urls and views

I try copy my object. I can receive copy from my "def checklist_copy" if i explicitly specify pk.(example)

But, i try work with '' and this is not work. I want to copy the object under which I click on the button

i used different variations: (pk=pk) in function, and in html template,

tried passing "self" to function and doing

doing pk=int( to then transfer this "pk" to (pk=pk) in

try include func in class DetailView

did not achieve a result

Please help. I don't know where and what to look for


from django.urls import reverse
from django.db import models

class Checklist(models.Model):
    title = models.CharField(max_length=250)

    def get_absolute_url(self):
        return reverse ('checklist:checklist', kwargs={'id':, 'title': self.title})

    def __str__(self):
        return self.title

from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from .models import Checklist
from django.shortcuts import redirect
from django.urls import reverse_lazy
class CheckListView(ListView):
    model = Checklist
    context_object_name = 'checklists'

class CheckListDetail(DetailView):
    model = Checklist
    context_object_name = 'checkList'
    template_name = 'base/checklist.html'

def checklist_copy(request):
    dest = Checklist.objects.get(pk=2) #here i need to use, but can't include 'self' in args of func = None
    return redirect(reverse_lazy('checklists')) (my app)

from django.urls import path
from .views import CheckListView, CheckListDetail
from . import views

urlpatterns = [
    path('', CheckListView.as_view(), name='checklists'),
    path('checklist/<int:pk>/', CheckListDetail.as_view(), name='checklist'),
    path('checklist-copy/', views.checklist_copy, name='checklist_copy'),


<div id="tasklist" class="task-items-wrapper">
{% for checklist in checklists %}
<div class="task-wrapper" data-position="{{}}">
    <div class="task-title">
        <a href="{% url 'checklist' %}">{{checklist}}</a> 

<a class="task-wrapper" href="{% url 'checklist_copy' %}">Copy</a>

{% endfor %}
Back to Top