Commit 8e125393 authored by Jan Ericsson Ong Ang's avatar Jan Ericsson Ong Ang

Edited addbook and addauthor urls and abosulte url

parent 519e668e
from django.db import models
from django.urls import reverse
# Create your models here.
class Author(models.Model):
......@@ -12,7 +13,7 @@ class Author(models.Model):
return self.first_name + " " + self.last_name
def get_absolute_url(self):
return reverse('product_change', kwargs={'id': self.id})
return reverse('bookshelf:author-detail', kwargs={'id': self.id})
#https://stackoverflow.com/questions/70442828/django-object-list-from-listview-with-two-models%20#}%20{%%20for%20object%20in%20author.books_set.all
# for absolute url and _set_all
......@@ -26,4 +27,8 @@ class Books(models.Model):
blurb = models.TextField(max_length=10000)
def __str__(self):
return self.title
\ No newline at end of file
return self.title
def get_absolute_url(self):
return reverse('bookshelf:books-detail', kwargs={'id': self.id})
\ No newline at end of file
......@@ -8,11 +8,11 @@ urlpatterns = [
path('', views.HomeView, name='home'),
path('authors/', AuthorView.as_view(), name='authors'),
path('authors/<int:id>/details/', AuthorDetailView.as_view(), name='author-detail'),
path('authors/<int:id>/add/', AuthorCreateView.as_view(), name='add-author'),
path('authors/add/', AuthorCreateView.as_view(), name='add-author'),
path('authors/<int:id>/edit/', AuthorUpdateView.as_view(), name='edit-author'),
path('books/', BooksView.as_view(), name='books'),
path('books/<int:id>/details/', BookDetailView.as_view(), name='books-detail'),
path('books/<int:id>/add/', BooksCreateView.as_view(), name='add-book'),
path('books/add/', BooksCreateView.as_view(), name='add-book'),
path('books/<int:id>/edit/', BooksUpdateView.as_view(), name='edit-book'),
]
......
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