Add view detail for wishlist and wisht
This commit is contained in:
parent
52063691bb
commit
ce3684fe67
|
@ -18,9 +18,9 @@ Including another URLconf
|
|||
from django.conf.urls import include, url
|
||||
from django.contrib import admin
|
||||
|
||||
from wish.views import WishListList
|
||||
import wish
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^$', WishListList.as_view(), name='wishlists'),
|
||||
url(r'^', include('wish.urls', namespace='wish')),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<p>Mes listes de souhaits</p>
|
||||
<ul>
|
||||
{% for wishlist in wishlists %}
|
||||
<li>{{ wishlist.name }}: {{ wishlist.description }}</li>
|
||||
<li><a href="{% url "wish:wishlist" wishlist.pk %}">{{ wishlist.name }}</a>: {{ wishlist.description }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h3>Liste {{ wishlist.name }}</h3>
|
||||
<div>
|
||||
{{ wishlist.description }}
|
||||
</div>
|
||||
<div>
|
||||
<ul>
|
||||
{% for wish in wishlist.items.all %}
|
||||
<li><a href="{% url "wish:wish" wish.pk %}">{{ wish.name }}</a>: {{ wish.description }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h3>{{ wish.name }}</h3>
|
||||
<div>
|
||||
{{ wish.description }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
# gwift/urls.py
|
||||
|
||||
"""gwift URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/1.8/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Add an import: from blog import urls as blog_urls
|
||||
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
|
||||
"""
|
||||
from django.conf.urls import url
|
||||
|
||||
from .views import WishListList, WishListDetail, WishDetail
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', WishListList.as_view(), name='wishlists'),
|
||||
url(r'^list/(?P<pk>\d+)/$', WishListDetail.as_view(), name='wishlist'),
|
||||
url(r'^wish/(?P<pk>\d+)/$', WishDetail.as_view(), name='wish'),
|
||||
]
|
|
@ -1,11 +1,21 @@
|
|||
# wish/views.py
|
||||
|
||||
from django.views.generic import ListView
|
||||
from django.views.generic import ListView, DetailView
|
||||
|
||||
from .models import Wishlist
|
||||
from .models import Wish, Wishlist
|
||||
|
||||
|
||||
class WishListList(ListView):
|
||||
context_object_name = 'wishlists'
|
||||
model = Wishlist
|
||||
template_name = 'wish/list.html'
|
||||
|
||||
class WishListDetail(DetailView):
|
||||
context_object_name = 'wishlist'
|
||||
model = Wishlist
|
||||
template_name = 'wish/list_detail.html'
|
||||
|
||||
class WishDetail(DetailView):
|
||||
context_object_name = 'wish'
|
||||
model = Wish
|
||||
template_name = 'wish/wish_detail.html'
|
||||
|
|
Loading…
Reference in New Issue