Commit 54e0caad authored by RJC's avatar RJC

added authorcreateview to views.py in bookshelf module

parent 069233c1
{% extends 'base.html' %}
{% block title %}Add New Author{% endblock %}
{% block header %}Add New Author{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Add Author">
</form>
{% endblock %}
\ No newline at end of file
from django.shortcuts import render
from django.views import generic
from django.urls import reverse
from .models import Books, Author
# Create your views here.
......@@ -21,6 +22,10 @@ class BookCreateView(generic.CreateView):
fields = '__all__'
template_name = 'bookshelf/add-book.html'
def get_success_url(self):
return reverse('bookshelf:bookdetailview', kwargs={'pk': self.object.id},
current_app=self.request.resolver_match.namespace)
class BookDetailView(generic.DetailView):
model = Books
......@@ -36,6 +41,16 @@ class AuthorListView(generic.ListView):
context_object_name = 'authors'
class AuthorCreateView(generic.CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.html'
def get_success_url(self):
return reverse('bookshelf:authordetailview', kwargs={'pk': self.object.id},
current_app=self.request.resolver_match.namespace)
class AuthorDetailView(generic.DetailView):
model = Author
template_name = 'bookshelf/author_detail.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