Commit a56439b0 authored by Jan Enzo Salvador's avatar Jan Enzo Salvador

Added get_absolute_url function to all models

parent bfb08952
from django.db import models
from django.urls import reverse
class Author(models.Model):
first_name = models.CharField(max_length = 50, default = "")
......@@ -9,6 +10,9 @@ class Author(models.Model):
def __str__(self):
return self.last_name
def get_absolute_url(self):
return reverse('bookshelf:author-details', kwargs={'pk':self.pk})
class Books(models.Model):
title = models.CharField(max_length = 50, default = "")
......@@ -20,3 +24,6 @@ class Books(models.Model):
def __str__(self):
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