I've finished a Django tutorial a few days ago and I've started to recap the functionalities in my application. In my models.py I've stumbled upon a method and the kwargs thing it's not that clearly to me. What is the logic behind this, can you explain to me what it does? Thank you.
models.py
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
from django.urls import reverse
class Creation(models.Model):
title = models.CharField(max_length=100)
content = models.TextField()
date_posted = models.DateTimeField(default=timezone.now)
author = models.ForeignKey(User, on_delete=models.CASCADE)
likes = models.ManyToManyField(User, related_name='creation_posts')
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('blog:detail', kwargs={'pk': self.pk})
def total_likes(self):
return self.likes.count()
What does kwargs={'pk':self.pk}) do exactly? Thank you