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