created get absolute url method under Book models

parent 3cc3c9dd
from django.db import models from django.db import models
from django.urls import reverse
#Author #Author
#first_name; last_name; age; nationality; bio #first_name; last_name; age; nationality; bio
...@@ -27,4 +28,8 @@ class Book(models.Model): ...@@ -27,4 +28,8 @@ class Book(models.Model):
def __str__(self): def __str__(self):
return self.title return self.title
def get_absolute_url(self):
return(reverse('bookshelf:book-details', kwargs={'pk' : self.pk}))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment