Commit fb4b63f6 authored by Ron Rodillas's avatar Ron Rodillas

created the add book and author pages

parent 430435c2
{% extends 'base.html' %}
{% load static %}
{% block title %}
Add New Author
{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Add Author">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}
Add New Book
{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Add Book">
</form>
{% endblock %}
\ No newline at end of file
......@@ -33,5 +33,9 @@ div {
<a href="{% url 'bookshelf:BooksView' %}"> Books</a>
&nbsp;&nbsp;&nbsp;
<a href="{% url 'bookshelf:AuthorsView' %}"> Authors</a>
<br>
<a href="{% url 'bookshelf:AddBook' %}"> Add Book</a>
&nbsp;&nbsp;&nbsp;
<a href="{% url 'bookshelf:AddAuthor' %}"> Add Author</a>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import home, BooksView, AuthorsView, BookDetailView, AuthorDetailView
from .views import *
urlpatterns = [
path('', home, name='home'),
path('books/', BooksView.as_view(), name='BooksView'),
path('authors/', AuthorsView.as_view(), name='AuthorsView'),
path('books/<int:pk>/details', BookDetailView.as_view(), name='BookDetailView'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='AuthorDetailView')
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='AuthorDetailView'),
path ('books/add', BooksCreateView.as_view(), name='AddBook'),
path ('authors/add/', AuthorCreateView.as_view(), name='AddAuthor'),
]
app_name="bookshelf"
\ No newline at end of file
......@@ -2,7 +2,9 @@ from django.shortcuts import render
from django.http import HttpResponse
from django.views import View
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import *
# Create your views here.
def home(request):
return render(request,"bookshelf/home.html")
......@@ -23,3 +25,12 @@ class BookDetailView(DetailView):
class AuthorDetailView(DetailView):
model = Author
class BooksCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/add-book.html'
class AuthorCreateView(CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.html'
\ 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