Buttons now properly linked to Edit HTML files

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