LoginSignup
0
2

More than 5 years have passed since last update.

【作成中】DjangoでWebアプリケーションを作ってみる

Posted at

これに沿って作ってみる。
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'),
]

参考:https://teratail.com/questions/88819

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2