Added get_update_url() functions to the models to return URLs needed for updating data

parent 29ce1246
...@@ -15,6 +15,9 @@ class Author(models.Model): ...@@ -15,6 +15,9 @@ class Author(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('bookshelf:author-item', kwargs={'pk': self.pk}) return reverse('bookshelf:author-item', kwargs={'pk': self.pk})
def get_update_url(self):
return reverse('bookshelf:author-edit', kwargs={'pk': self.pk})
class Books(models.Model): class Books(models.Model):
title = models.CharField(max_length=255, blank=True, null=True) title = models.CharField(max_length=255, blank=True, null=True)
...@@ -29,4 +32,7 @@ class Books(models.Model): ...@@ -29,4 +32,7 @@ class Books(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('bookshelf:book-item', kwargs={'pk': self.pk}) return reverse('bookshelf:book-item', kwargs={'pk': self.pk})
def get_update_url(self):
return reverse('bookshelf:book-edit', kwargs={'pk': self.pk})
\ No newline at end of file
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