Commit a719b59d authored by Nics De Vega's avatar Nics De Vega

Initial commit to new branch, updated README.txt and added initial html files with views and urls

parent 8922ea7e
......@@ -7,8 +7,11 @@
<h4 class="text-center">I usually like books with religious themes that make me go <b>Insane</b>. I also like Revue Starlight!</p>
<h2 class="text-center">
<small>
<a href="/bookshelf/books/">Books</a>
<a href="/bookshelf/authors/">Authors</a>
<a href="../books/">Books</a>
<a href="../authors/">Authors</a>
<br>
<a href="../books/add">Add Book</a>
<a href="../authors/add">Add Author</a>
</small>
</h2>
......
from django.urls import path
from .views import homepage, index_view, BooksView, AuthorsView, BooksDetailView, AuthorsDetailView
from .views import homepage, index_view, BooksView, AuthorsView, BooksDetailView, AuthorsDetailView, BooksCreateView, BooksUpdateView, AuthorsCreateView, AuthorsUpdateView
urlpatterns = [
path('',index_view,name='index'),
path('home/',homepage,name='home'),
path('books/',BooksView.as_view(),name='books'),
path('authors/',AuthorsView.as_view(),name='authors'),
path('books/<int:pk>/details/',BooksDetailView.as_view(),name='book_details'),
path('authors/<int:pk>/details/',AuthorsDetailView.as_view(),name='author_details')
path('books/add/',BooksCreateView.as_view(),name='add_book'),
path('books/<int:pk>/edit/',BooksUpdateView.as_view(),name='update_book'),
path('authors/',AuthorsView.as_view(),name='authors'),
path('authors/<int:pk>/details/',AuthorsDetailView.as_view(),name='author_details'),
path('authors/add/',AuthorsCreateView.as_view(),name='add_author'),
path('authors/<int:pk>/edit/',BooksUpdateView.as_view(),name='update_author'),
]
app_name = 'bookshelf'
\ No newline at end of file
......@@ -3,12 +3,13 @@ from django.http import HttpResponse
from .models import Author, Book
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
def index_view(request):
return HttpResponse("<h3>Hello Welcome to My Bookshelf! Please go to another page lmao.</h3>")
def homepage(request):
return render(request, 'bookshelf/home.html', {'name': 'homepage'})
return render(request, 'bookshelf/home.html', {'name': 'Nics'})
class BooksView(ListView):
model = Book
......@@ -18,10 +19,30 @@ class BooksDetailView(DetailView):
model = Book
template_name = "bookshelf/book_details.html"
class BooksCreateView(CreateView):
model = Book
fields = '__all__'
template_name = "bookshelf/add_book.html"
class BooksUpdateView(UpdateView):
model = Book
fields = '__all__'
template_name = "bookshelf/edit_book.html"
class AuthorsView(ListView):
model = Author
template_name = "bookshelf/authors.html"
class AuthorsDetailView(DetailView):
model = Author
template_name = "bookshelf/author_details.html"
\ No newline at end of file
template_name = "bookshelf/author_details.html"
class AuthorsCreateView(CreateView):
model = Author
fields = '__all__'
template_name = "bookshelf/add_author.html"
class AuthorsUpdateView(UpdateView):
model = Book
fields = '__all__'
template_name = "bookshelf/edit_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