Commit c6350594 authored by Washington99's avatar Washington99

Fix for add function bug in home

Fixed this error: Generic detail view must be called with either an object pk or a slug.

I simply renamed the functions for create and edit views such that they're not the same.
parent e7cd1f8f
......@@ -22,8 +22,8 @@
<a href="/books">Books</a>
</div>
<div>
<a href="/authors/add">Add Author</a>
<a href="/books/add">Add Book</a>
<a href="/authors/add/">Add Author</a>
<a href="/books/add/">Add Book</a>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import home_view, AuthorList, BookList, AuthorView, BookView
from .views import AuthorCreateView, BooksCreateView
from .views import AuthorCreateView, BooksCreateView, AuthorEditView, BooksEditView
urlpatterns = [
path('home/', home_view, name = 'home_view'),
......@@ -9,9 +9,9 @@ urlpatterns = [
path('authors/<int:pk>/details/', AuthorView.as_view(), name = 'authors_details'),
path('books/<int:pk>/details/', BookView.as_view(), name = 'books_details'),
path('authors/add/', AuthorCreateView.as_view(), name = 'add-author'),
path('authors/<int:pk>/edit/', AuthorCreateView.as_view(), name = 'edit-author'),
path('authors/<int:pk>/edit/', AuthorEditView.as_view(), name = 'edit-author'),
path('books/add/', BooksCreateView.as_view(), name = 'add-book'),
path('books/<int:pk>/edit/', BooksCreateView.as_view(), name = 'edit-book')
path('books/<int:pk>/edit/', BooksEditView.as_view(), name = 'edit-book')
]
app_name = "bookshelf"
......
......@@ -44,7 +44,7 @@ class AuthorCreateView(CreateView):
else:
return render(request, self.template_name, {'form': form})
class AuthorCreateView(UpdateView):
class AuthorEditView(UpdateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/edit-author.html'
......@@ -67,7 +67,7 @@ class BooksCreateView(CreateView):
else:
return render(request, self.template_name, {'form': form})
class BooksCreateView(UpdateView):
class BooksEditView(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
......
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