質問するログイン新規登録

質問編集履歴

1

入力したコードを質問に記載しました。

2018/12/11 09:57

投稿

sunap220
sunap220

スコア23

title CHANGED
File without changes
body CHANGED
@@ -2,7 +2,9 @@
2
2
  他の事例を検索し、調べるも解決できませんでした。
3
3
  回答のほどよろしくお願い致します。
4
4
 
5
+ web_projプロジェクトの中にhelloアプリケーション作成を行っていました。
6
+
5
- ```Django
7
+ ```terminal
6
8
  Performing system checks...
7
9
 
8
10
  Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10e26ce18>
@@ -42,4 +44,156 @@
42
44
  File "/Users/********/Programing_box/pydataenv/lib/python3.7/site-packages/django/urls/conf.py", line 39, in include
43
45
  'Specifying a namespace in include() without providing an app_name '
44
46
  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.
47
+ ```
48
+
49
+ web_proj/settings.py 以下
50
+
51
+ ```ここに言語を入力
52
+ import os
53
+
54
+ # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
55
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
56
+
57
+
58
+ # Quick-start development settings - unsuitable for production
59
+ # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
60
+
61
+ # SECURITY WARNING: keep the secret key used in production secret!
62
+ SECRET_KEY = 'i72y3=nl%5fxh#(e-gi=+sq6$@ay6ot#b!_kyw=igsh18#5fu6'
63
+
64
+ # SECURITY WARNING: don't run with debug turned on in production!
65
+ DEBUG = True
66
+
67
+ ALLOWED_HOSTS = []
68
+
69
+
70
+ # Application definition
71
+
72
+ INSTALLED_APPS = [
73
+ 'django.contrib.admin',
74
+ 'django.contrib.auth',
75
+ 'django.contrib.contenttypes',
76
+ 'django.contrib.sessions',
77
+ 'django.contrib.messages',
78
+ 'django.contrib.staticfiles',
79
+ 'hello',
80
+ ]
81
+
82
+ MIDDLEWARE = [
83
+ 'django.middleware.security.SecurityMiddleware',
84
+ 'django.contrib.sessions.middleware.SessionMiddleware',
85
+ 'django.middleware.common.CommonMiddleware',
86
+ 'django.middleware.csrf.CsrfViewMiddleware',
87
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
88
+ 'django.contrib.messages.middleware.MessageMiddleware',
89
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
90
+ ]
91
+
92
+ ROOT_URLCONF = 'web_proj.urls'
93
+
94
+ TEMPLATES = [
95
+ {
96
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
97
+ 'DIRS': [],
98
+ 'APP_DIRS': True,
99
+ 'OPTIONS': {
100
+ 'context_processors': [
101
+ 'django.template.context_processors.debug',
102
+ 'django.template.context_processors.request',
103
+ 'django.contrib.auth.context_processors.auth',
104
+ 'django.contrib.messages.context_processors.messages',
105
+ ],
106
+ },
107
+ },
108
+ ]
109
+
110
+ WSGI_APPLICATION = 'web_proj.wsgi.application'
111
+
112
+
113
+ # Database
114
+ # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
115
+
116
+ DATABASES = {
117
+ 'default': {
118
+ 'ENGINE': 'django.db.backends.sqlite3',
119
+ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
120
+ }
121
+ }
122
+
123
+
124
+ # Password validation
125
+ # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
126
+
127
+ AUTH_PASSWORD_VALIDATORS = [
128
+ {
129
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
130
+ },
131
+ {
132
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
133
+ },
134
+ {
135
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
136
+ },
137
+ {
138
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
139
+ },
140
+ ]
141
+
142
+
143
+ # Internationalization
144
+ # https://docs.djangoproject.com/en/2.1/topics/i18n/
145
+
146
+ LANGUAGE_CODE = 'ja'
147
+
148
+ TIME_ZONE = 'Asia/Tokyo'
149
+
150
+ USE_I18N = True
151
+
152
+ USE_L10N = True
153
+
154
+ USE_TZ = True
155
+
156
+
157
+ # Static files (CSS, JavaScript, Images)
158
+ # https://docs.djangoproject.com/en/2.1/howto/static-files/
159
+
160
+ STATIC_URL = '/static/'
161
+ ```
162
+
163
+ hello/views.py 以下
164
+
165
+ ```ここに言語を入力
166
+ from django.http.response import HttpResponse
167
+
168
+ # Create your views here.
169
+
170
+
171
+ def hello_world(request):
172
+ return HttpResponse('Hello World!')
173
+
174
+
175
+ ```
176
+
177
+ hello/urls.py 以下
178
+
179
+ ```ここに言語を入力
180
+ from django.conf.urls import url
181
+ from . import views
182
+
183
+
184
+ urlpatterns = [
185
+ url(r'^$', views.hello_world, name = 'hello_world'),
186
+ ]
187
+ ```
188
+
189
+ web_proj/urls.py 以下
190
+
191
+ ```ここに言語を入力
192
+ from django.conf.urls import include, url
193
+
194
+
195
+ urlpatterns = [
196
+ url(r'^hello/', include('hello.urls', namespace='hello')),
197
+ ]
198
+
45
199
  ```