Buttons now properly linked to Edit HTML files

parent f434234e
......@@ -15,9 +15,6 @@ class Author(models.Model):
def get_absolute_url(self):
return reverse('bookshelf:authors-detail', kwargs={'pk': self.pk})
def get_edit_url(self):
return reverse('bookshelf:authors-edit', kwargs={'pk': self.pk})
class Books(models.Model):
title = models.CharField(max_length=1000)
author = models.ForeignKey(
......
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ author.first_name }}{% endblock %}
{% block title %} {{ author.first_name }} {{ author.last_name }}{% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'details_style.css' %}">
<link rel="stylesheet" href="{% static 'details_style.css' %}">
<h1>{{ author.first_name }} {{author.last_name}}</h1>
<ul>
<li>Age: {{ author.age }}</li>
......@@ -12,9 +12,10 @@
<li>{{ author.bio }}</li>
</div>
</ul>
<button onclick="window.location.href='../../../authors/{{author.id}}/edit/';">Edit Author</button><br/>
<p>
<a href="http://127.0.0.1:8000/bookshelf/home">Home</a>
<a href="http://127.0.0.1:8000/bookshelf/books">Books</a>
<a href="http://127.0.0.1:8000/bookshelf/authors">Authors</a>
</p>
{% endblock %}
\ No newline at end of file
{% endblock %}
\ No newline at end of file
......@@ -14,6 +14,7 @@
<li>{{ object.blurb }}</li>
</div>
</ul>
<button onclick="window.location.href='../../../books/{{object.id}}/edit/';">Edit Book</button><br/>
<p>
<a href="http://127.0.0.1:8000/bookshelf/home">Home</a>
<a href="http://127.0.0.1:8000/bookshelf/books">Books</a>
......
......@@ -4,8 +4,7 @@ from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from django.http import HttpResponse
from django.shortcuts import render, redirect, get_object_or_404
from django.urls import reverse_lazy
from django.shortcuts import render, redirect
from .models import Author, Books
from .forms import AuthorForm, BookForm
......@@ -56,13 +55,6 @@ class BooksUpdateView(UpdateView):
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
def edit_author(request, id):
author = get_object_or_404(Author, id=id)
if request.method == 'GET':
return render(request, 'bookshelf/edit-author.html',
{'form': AuthorForm(instance=author), 'id': id})
'''
def author_view(request):
if request.method == 'POST':
form = AuthorForm(request.POST)
......@@ -81,5 +73,4 @@ def book_view(request):
return redirect(AuthorsDetailView, pk=new_author.pk)
else:
form = AuthorForm()
return render(request, 'edit-book.html', {'form': form})
'''
\ No newline at end of file
return render(request, 'edit-book.html', {'form': form})
\ 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