質問編集履歴

2

ミスを修正

2018/05/14 02:07

投稿

wowow
wowow

スコア12

test CHANGED
File without changes
test CHANGED
@@ -8,15 +8,17 @@
8
8
 
9
9
  <追記>
10
10
 
11
- ```python(models.py)
11
+ models.py
12
+
13
+ ```python
12
14
 
13
15
  image = models.ImageField(upload_to='media/')
14
16
 
15
17
  ```
16
18
 
19
+ settings.py
17
20
 
18
-
19
- ```python(settings.py)
21
+ ```python
20
22
 
21
23
  STATIC_URL = '/static/'
22
24
 
@@ -28,9 +30,9 @@
28
30
 
29
31
  ```
30
32
 
33
+ urls.py
31
34
 
32
-
33
- ```python(urls.py)
35
+ ```python
34
36
 
35
37
  urlpatterns = [
36
38
 

1

コードの追記

2018/05/14 02:06

投稿

wowow
wowow

スコア12

test CHANGED
File without changes
test CHANGED
@@ -3,3 +3,39 @@
3
3
  登録フォームで画像を選択しているのに、何度フォームを送信しても「このフィールドは必須です」とでて送信できません。
4
4
 
5
5
  原因に心当たりのある方はいらっしゃいませんか?
6
+
7
+
8
+
9
+ <追記>
10
+
11
+ ```python(models.py)
12
+
13
+ image = models.ImageField(upload_to='media/')
14
+
15
+ ```
16
+
17
+
18
+
19
+ ```python(settings.py)
20
+
21
+ STATIC_URL = '/static/'
22
+
23
+ STATICFILES_DIRS = ( os.path.join('static'), )
24
+
25
+ MEDIA_URL = '/pics/'
26
+
27
+ MEDIA_ROOT = BASE_DIR
28
+
29
+ ```
30
+
31
+
32
+
33
+ ```python(urls.py)
34
+
35
+ urlpatterns = [
36
+
37
+ url(r'^admin/', admin.site.urls),
38
+
39
+ ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
40
+
41
+ ```