演習課題「記事詳細ページを作成する」
右の環境には、「myblog」プロジェクトに「news」というアプリケーションが作成してあります。また、プロジェクトとnewsアプリのルーティングは、以下のアクセスが可能になるよう設定してあります。
 news/
 news/(id)
views.pyを修正して、クラスベースの汎用ビューで記事詳細ページを作成してください。
採点して、すべてのジャッジに正解すれば、演習課題クリアです!
#07:お店の詳細ページを作ろう
ここでは、Lunchmapアプリでお店の詳細ページを作ります。詳細ページも、クラスベース汎用ビューを使うことで、少ないコードで記述できます。
myapp/lunchmap/urls.pyurlpatterns = [
    path('', views.IndexView.as_view(), name='index'),
    path('<int:pk>/', views.DetailView.as_view(), name='detail'),
]
myapp/lunchmap/views.pyfrom django.urls import reverse_lazy
from django.views import generic
from .models import Shop
class IndexView(generic.ListView):
    model = Shop
class DetailView(generic.DetailView):
    model = Shop
myapp/lunchmap/templates/lunchmap/shop_detail.html{% extends './base.html' %}
{% block content %}
<h1>{{ shop.name }}</h1>
<div>
    <p>{{ shop.category.name }}</p>
    <p>{{ shop.address }}</p>
</div>
<div>
    <a href='{% url "lunchmap:index" %}'>一覧</a>
</div>
{% endblock %}
myapp/lunchmap/templates/lunchmap/shop_list.html{% extends './base.html' %}
{% block content %}
<h1>お店一覧</h1>
<table class='table table-striped table-hover'>
    <tr>
        <th>カテゴリ</th><th>店名</th><th>住所</th>
    </tr>
    {% for shop in object_list %}
    <tr>
        <td>{{ shop.category.name }}</td>
        <td><a href='{% url "lunchmap:detail" shop.pk %}'>{{ shop.name }}</a></td>
        <td>{{ shop.address }}</td>
    </tr>
    {% endfor %}
</table>
{% endblock %}
- Django
 https://www.djangoproject.com/
- Django ドキュメント | Django documentation | Django
 https://docs.djangoproject.com/ja/2.0/
- Home | djangoproject.jp
 http://djangoproject.jp/
- Djangoウェブフレームワーク (Python) - ウェブ開発を学ぶ | MDN
 https://developer.mozilla.org/ja/docs/Learn/Server-side/Django
- ★ Djangoでの開発 ダイジェスト - Qiita
 https://qiita.com/zaburo/items/0e15f6c150caa13ca34c
- Django入門: 初心者でも10分でWebサービスを作れる!PythonフレームワークDjangoとPaizaCloudの使い方 - paiza開発日誌
 https://paiza.hatenablog.com/entry/2018/02/28/paizacloud_django