これに沿って作ってみる。
https://eiry.bitbucket.io/index.html
詰まったところ
Django アプリケーションを作ろう
mysiteフォルダーの中にhelloフォルダーが作られます。
そうならなかったので、手動で「hello」フォルダをmysite配下に移動した。
ビュー関数とURLConfを書こう
hello.urls.pyの編集内容
サイトの通り実装すると次のエラーが発生する。
File "/Users/****/PycharmProjects/practice/mysite/mysite/urls.py", line 22, in <module>
url(r'^hello/', include('hello.urls', namespace='hello')),
File "/Users/****/wk_yuta/PycharmProjects/practice/venv/lib/python3.7/site-packages/django/urls/conf.py", line 39, in include
'Specifying a namespace in include() without providing an app_name '
django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.
これを解消するため、app_nameを記述する。
from django.conf.urls import url
from . import views
# このapp_nameを追加する
app_name = "hello"
urlpatterns = [
url(r'^$', views.hello_world, name='hello_world'),
]