Commit 4c57678c authored by Washington99's avatar Washington99

Merge branch 'lab04' into CSS

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