diff --git a/wishlist/urls.py b/wishlist/urls.py index 47b6ddb..61b2a9b 100644 --- a/wishlist/urls.py +++ b/wishlist/urls.py @@ -2,7 +2,7 @@ from django.urls import path from . import views as v urlpatterns = [ -# path('user/', ...), -# path('item/', ...), -# path('', ...), + path('user/', v.UserWishLists.as_view(), name='wishlists_user'), + path('item/', v.WishedItemView.as_view(), name='wished_item'), + path('', v.WishListView.as_view(), name='wishlist'), ] diff --git a/wishlist/views.py b/wishlist/views.py index 91ea44a..9b18ac5 100644 --- a/wishlist/views.py +++ b/wishlist/views.py @@ -1,3 +1,23 @@ from django.shortcuts import render +import wishlist.models as m +import django.views.generic as dv -# Create your views here. +class WishedItemView(dv.DetailView): + model = m.WishedItem + template_name = ... + +class UserWishLists(dv.ListView): + model = m.WishList + template_name = ... + + def get_queryset(self): + qs = super().get_queryset() + return qs.filter(owner__login=self.loginname) + +class WishListView(dv.ListView): + model = m.WishedItem + template_name = ... + + def get_queryset(self): + qs = super().get_queryset() + return qs.filter(wishlists__slug__in=[self.slug])