Commit 8ae0776b authored by Deokhyun Lee's avatar Deokhyun Lee

now design is added with static folder as a proper path. setting.py also include this path

parent a5d1ce08
......@@ -52,7 +52,8 @@ MIDDLEWARE = [
]
ROOT_URLCONF = 'Deokhyun_Lee_reading.urls'
STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / "static"]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
......
{% extends 'base.html'%}
{% block title %}
Add New Author
{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Add Author</button>
</form>
{% endblock %}
\ No newline at end of file
......@@ -22,5 +22,8 @@
{% else %}
<p>No Available Books.</p>
{% endif %}
<a href="/home">Home</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/books">Books</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/authors">Authors</a>
<ul>
<li ><button type="button" onclick="alert('You pressed the button!')">Click me!</button></li>
<li><a href="/home">Home</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/books">Books</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/authors">Authors</a></li>
</ul>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import HomeView, AuthorListView, AuthorDetailView, BookListView, BookDetailView, BookAddListView
from .views import HomeView, AuthorListView, AuthorDetailView, AuthorAddListView ,BookListView, BookDetailView, BookAddListView
urlpatterns = [
# for Home (landing page)
......@@ -7,6 +7,7 @@ urlpatterns = [
# for Authors page
path('authors/', AuthorListView.as_view(), name='authors'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='author_detail'),
path('authors/add',AuthorAddListView.as_view(), name="add_author" ),
# for Books page
path('books/', BookListView.as_view(), name='books'),
path('books/<int:pk>/details', BookDetailView.as_view(), name='book_detail'),
......
......@@ -3,7 +3,7 @@ from django.shortcuts import render, redirect
from django.views.generic import ListView, DetailView, CreateView
from django.shortcuts import render
from .models import Author, Book
from .forms import AddBookForm
from .forms import AddBookForm, AddAuthorForm
# View for Home (landing page)
class HomeView(View):
......@@ -57,3 +57,17 @@ class BookAddListView(CreateView):
else:
return render(request, 'book_details.html', {'form': form})
class AuthorAddListView(CreateView):
model = Author
fields = '__all__'
template_name = "authors/add-author.html"
def post(self, request):
form = AddAuthorForm(request.POST)
if form.is_valid():
# onSave is called, the form will have essential data and this includes pk as well.
new_author = form.save()
# pass the pk and redirect.
return redirect('author_detail', pk = new_author.pk)
else:
return render(request, 'author_details.html', {'form': form})
\ No newline at end of file
.row {
grid-row: 1 / span 2;
}
ul li {
list-style-type: none;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="styleshost" href="styles.css">
{% load static %}
<link rel="stylesheet" href="{% static 'styles.css' %}">
<title>{% block title %}{% endblock %}</title>
</head>
<body>
......
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