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

質問編集履歴

8

誤字の修正

2020/09/28 02:40

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
  def get_form_kwargs(self):
38
38
  kwargs = super(CompanyCreateView,self).get_form_kwargs()
39
- kwargs['test_sevice_id'] =self.kwargs['sevice_id'] #service_idはパラメータ
39
+ kwargs['test_service_id'] =self.kwargs['sevice_id'] #service_idはパラメータ
40
40
  return kwargs
41
41
  ```
42
42
  ●urls.py

7

情報の追加

2020/09/28 02:40

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -260,6 +260,7 @@
260
260
  エラー内容から引数の設定の問題かもしれませんが、よくわかりません。
261
261
  よろしくお願いします。
262
262
 
263
+
263
264
  ### 補足情報(FW/ツールのバージョンなど)
264
265
 
265
266
  django=2.2

6

情報の追加

2020/09/27 23:18

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -212,6 +212,30 @@
212
212
  </div>
213
213
  {% endblock %}
214
214
  ```
215
+ ディレクトリ構造
216
+ ```ここに言語を入力
217
+ myproject
218
+ |_company
219
+ |___pycache__
220
+ |_migrations
221
+ |___init__.py
222
+ |_admin.py
223
+ |_forms.py
224
+ |_models.py
225
+ |_tests.py
226
+ |_urls.py
227
+ |_views.py
228
+ |_config
229
+ |___pycache__
230
+ |___init__.py
231
+ |_settings.py
232
+ |_urls.py
233
+ |_wsgi.py
234
+ |_templates
235
+ |_company
236
+ |_form.html
237
+ |_base.html
238
+ ```
215
239
  ### 発生している問題・エラーメッセージ
216
240
 
217
241
  ```

5

情報の追加

2020/09/27 23:12

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -193,6 +193,25 @@
193
193
  )
194
194
 
195
195
  ```
196
+ ●form.html
197
+ ```html
198
+ {% extends 'base.html' %}
199
+
200
+ {% block content %}
201
+ <div>
202
+ <h4>企業情報</h4>
203
+
204
+ <form method="post">
205
+ <table>
206
+ {% csrf_token %}
207
+ {{ form.as_p }}
208
+ </table>
209
+ <input type="submit" value="保存">
210
+ </form>
211
+
212
+ </div>
213
+ {% endblock %}
214
+ ```
196
215
  ### 発生している問題・エラーメッセージ
197
216
 
198
217
  ```

4

情報の修正

2020/09/27 23:01

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -138,7 +138,7 @@
138
138
  "HOST": "hostname",
139
139
  "PORT": "3306",
140
140
  },
141
- "jp-indexpro": {
141
+ "db2": {
142
142
  "ENGINE": "sql_server.pyodbc",
143
143
  "NAME": "dbname",
144
144
  "USER": "user",

3

情報の追加

2020/09/27 22:59

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -51,6 +51,148 @@
51
51
  path('<int:company_id>/create/<int:sevice_id>', views.CompanyCreateView.as_view(), name='service_create'),
52
52
  ]
53
53
  ```
54
+ ●settings.py
55
+ ```python
56
+ """
57
+ Django settings for config project.
58
+
59
+ Generated by 'django-admin startproject' using Django 2.2.12.
60
+
61
+ For more information on this file, see
62
+ https://docs.djangoproject.com/en/2.2/topics/settings/
63
+
64
+ For the full list of settings and their values, see
65
+ https://docs.djangoproject.com/en/2.2/ref/settings/
66
+ """
67
+
68
+ import os
69
+
70
+ # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
71
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
72
+
73
+
74
+ # Quick-start development settings - unsuitable for production
75
+ # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
76
+
77
+ # SECURITY WARNING: keep the secret key used in production secret!
78
+ SECRET_KEY = 'l_dil%jvy7)9f5%gr8fn(4sl0cx&tuc__o3!kf&1fzi-cw$+!e'
79
+
80
+ # SECURITY WARNING: don't run with debug turned on in production!
81
+ DEBUG = True
82
+
83
+ ALLOWED_HOSTS = ['127.0.0.1']
84
+
85
+
86
+ # Application definition
87
+
88
+ INSTALLED_APPS = [
89
+ 'company.apps.CompanyConfig',
90
+ 'django.contrib.admin',
91
+ 'django.contrib.auth',
92
+ 'django.contrib.contenttypes',
93
+ 'django.contrib.sessions',
94
+ 'django.contrib.messages',
95
+ 'django.contrib.staticfiles',
96
+ ]
97
+
98
+ MIDDLEWARE = [
99
+ 'django.middleware.security.SecurityMiddleware',
100
+ 'django.contrib.sessions.middleware.SessionMiddleware',
101
+ 'django.middleware.common.CommonMiddleware',
102
+ 'django.middleware.csrf.CsrfViewMiddleware',
103
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
104
+ 'django.contrib.messages.middleware.MessageMiddleware',
105
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
106
+ ]
107
+
108
+ ROOT_URLCONF = 'config.urls'
109
+
110
+ TEMPLATES = [
111
+ {
112
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
113
+ 'DIRS': [os.path.join(BASE_DIR, 'templates')],
114
+ 'APP_DIRS': True,
115
+ 'OPTIONS': {
116
+ 'context_processors': [
117
+ 'django.template.context_processors.debug',
118
+ 'django.template.context_processors.request',
119
+ 'django.contrib.auth.context_processors.auth',
120
+ 'django.contrib.messages.context_processors.messages',
121
+ ],
122
+ },
123
+ },
124
+ ]
125
+
126
+ WSGI_APPLICATION = 'config.wsgi.application'
127
+
128
+
129
+ # Database
130
+ # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
131
+
132
+ DATABASES = {
133
+ 'default': {
134
+ "ENGINE": "django.db.backends.mysql",
135
+ "NAME": "dbname",
136
+ "USER": "user",
137
+ "PASSWORD": "password",
138
+ "HOST": "hostname",
139
+ "PORT": "3306",
140
+ },
141
+ "jp-indexpro": {
142
+ "ENGINE": "sql_server.pyodbc",
143
+ "NAME": "dbname",
144
+ "USER": "user",
145
+ "PASSWORD": "password",
146
+ "HOST": "hostname",
147
+ "PORT": "",
148
+ "OPTIONS": {
149
+ "driver": "ODBC Driver 17 for SQL Server"
150
+ }
151
+ }
152
+ }
153
+
154
+ # Password validation
155
+ # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
156
+
157
+ AUTH_PASSWORD_VALIDATORS = [
158
+ {
159
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
160
+ },
161
+ {
162
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
163
+ },
164
+ {
165
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
166
+ },
167
+ {
168
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
169
+ },
170
+ ]
171
+
172
+
173
+ # Internationalization
174
+ # https://docs.djangoproject.com/en/2.2/topics/i18n/
175
+
176
+ LANGUAGE_CODE = 'ja'
177
+
178
+ TIME_ZONE = 'Asia/Tokyo'
179
+
180
+ USE_I18N = True
181
+
182
+ USE_L10N = True
183
+
184
+ USE_TZ = True
185
+
186
+
187
+ # Static files (CSS, JavaScript, Images)
188
+ # https://docs.djangoproject.com/en/2.2/howto/static-files/
189
+
190
+ STATIC_URL = '/static/'
191
+ STATICFILES_DIRS = (
192
+ os.path.join(BASE_DIR, "static"),
193
+ )
194
+
195
+ ```
54
196
  ### 発生している問題・エラーメッセージ
55
197
 
56
198
  ```

2

補足情報追記

2020/09/27 22:56

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -39,6 +39,18 @@
39
39
  kwargs['test_sevice_id'] =self.kwargs['sevice_id'] #service_idはパラメータ
40
40
  return kwargs
41
41
  ```
42
+ ●urls.py
43
+ ```python
44
+ from django.urls import path
45
+
46
+ from . import views
47
+
48
+ app_name = 'company'
49
+
50
+ urlpatterns = [
51
+ path('<int:company_id>/create/<int:sevice_id>', views.CompanyCreateView.as_view(), name='service_create'),
52
+ ]
53
+ ```
42
54
  ### 発生している問題・エラーメッセージ
43
55
 
44
56
  ```

1

文章の修正

2020/09/27 22:52

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- DjangoでviewからFormオブジェクトに値を渡したい
1
+ djangoでviewからFormオブジェクトに値を渡したい
body CHANGED
File without changes