Fixed urls and views since there werinternal errors from the computer

parent 99ba4695
......@@ -3,9 +3,9 @@ from .views import home_view, BooksView, BooksDetailView, AuthorView, AuthorDeta
urlpatterns = [
path('', home_view, name='home'),
path('books', BooksView.as_view(), name='books'),
path('books/', BooksView.as_view(), name='books'),
path('books/<int:pk>/details/', BooksDetailView.as_view(), name='book-details'),
path('author', AuthorView.as_view(), name='author'),
path('author/', AuthorView.as_view(), name='author'),
path('author/<int:pk>/details/', AuthorDetailView.as_view(), name='author-details'),
]
# This might be needed depending on your Django version
......
from django.http import render
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from .models import Books, Author
def home_view(request):
return render(request, 'bookshelf/home.html', {})
return render(request, 'bookshelf/home.html', {'nickname': 'Dani'})
class BooksView(ListView):
model = Books
template_name = 'bookshelf/books.html'
class BooksDetailView(DetailView):
model = Books
template_name = 'bookshelf/books_detail.html'
class AuthorView(ListView):
model = Author
template_name = 'bookshelf/author.html'
class AuthorDetailView(DetailView):
model = Author
\ No newline at end of file
model = Author
template_name = 'bookshelf/author_detail.html'
......@@ -18,7 +18,6 @@ from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('bookshelf/', include('bookshelf.urls',
namespace="<bookshelf")),
path('bookshelf/', include('bookshelf.urls',namespace="<bookshelf")),
path('admin/', admin.site.urls),
]
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