Commit 4dc16d41 authored by Star Neptune R. Sy's avatar Star Neptune R. Sy

front end of add-author is done. Along with the createView of both sites

parent e3dc6a99
{% extends 'base.html '%}
{% block title %} Add new book {% endblock %}
{% block title %} Add new Book {% endblock %}
{% block content %}
......@@ -27,3 +27,4 @@
</form>
{% endblock %}
......@@ -11,7 +11,7 @@
<a class="navBtn" href="/authors"> Authors</a>
<br>
<a class="navBtn" href="/books/add">Add Book</a>
<!--<a class="navBtn" href="/authors">Add Author</a>-->
<a class="navBtn" href="/authors/add">Add Author</a>
</div>
{% endblock %}
# bookshelf/urls.py
from django.urls import path
from .views import (homeView, BooksView, BooksAddView, BooksDetail, AuthorView, AuthorDetail)
from .views import (homeView, BooksView, BooksAddView, BooksDetail, AuthorView, AuthorAddView, AuthorDetail)
from django.conf.urls.static import static
urlpatterns = [
......@@ -11,7 +11,7 @@ urlpatterns = [
path('authors/<int:pk>/details/', AuthorDetail.as_view(), name="author_details"),
#path for the forms that add
path('books/add', BooksAddView.as_view(), name='add_books'),
#path('authors/add'),
path('authors/add', AuthorAddView.as_view(), name='add_author'),
]
# This might be needed, depending on your Django version
......
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, UpdateView
from .models import Author, Book
def homeView(request):
......@@ -12,8 +13,9 @@ class BooksView(ListView):
template_name = "bookshelf/books.html"
class BooksAddView(ListView):
class BooksAddView(CreateView):
model = Author
fields='__all__'
template_name = "bookshelf/add-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