質問編集履歴

5

修正

2024/07/11 00:22

投稿

student
student

スコア76

test CHANGED
File without changes
test CHANGED
@@ -24,13 +24,58 @@
24
24
 
25
25
  ### 該当のソースコード
26
26
 
27
+ ```base.html
28
+ {% load static %}<!-- static設定を読み込む -->
29
+ {% load django_bootstrap5 %}
30
+
31
+ <!DOCTYPE html>
32
+ <html lang="ja">
33
+ <head>
34
+ <meta charset="UTF-8">
35
+ <meta http-equiv="content-language" content="ja">
36
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
27
- ```project_name/urls.html
37
+ <title>TEST</title>
38
+ <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
39
+ <link href="{% static 'vendor/bootstrap/css/bootstrap-grid.min.css' %}" rel="stylesheet">
40
+ <link href="{% static 'moomin.css' %}" rel="stylesheet">
41
+ <script src="{% static 'vendor/jquery/jquery-3.2.1.min.js' %}"></script>
42
+ <script src="{% static 'vendor/bootstrap/js/bootstrap.min.js' %}"></script>
43
+
44
+ {% block meta_tag %}{% endblock %}
45
+ {% block css %}{% endblock %}
46
+ {% bootstrap_css %}
47
+ {% bootstrap_javascript %}
48
+
49
+ <!--css-->
50
+ <link href="{% static 'css/app.css' %}" rel="stylesheet">
51
+ <link href="{% static 'css/header.css' %}" rel="stylesheet">
52
+ <link href="{% static 'css/base.css' %}" rel="stylesheet">
53
+ <link href="{% static 'css/queries.css' %}" rel="stylesheet">
54
+
55
+ <!--JavaScript-->
56
+
57
+ </head>
58
+
59
+ <body class="bg-dark">
60
+ {% include 'nav.html' %} <!-- nav.htmlの記述を持ってくる -->
61
+ {% block contents %}{% endblock %}
62
+ </body>
63
+ <script src="{% static 'js/jquery-3.4.1.min.js' %}"></script>
64
+ <script src="{% static 'js/bootstrap.bundle.min.js' %}"></script>
65
+
66
+ </html>
67
+
68
+ ```
69
+
70
+ ```templates/allauth/account/login.html
28
- {% extends "account/base.html" %}
71
+ {% extends "base.html" %}
29
72
  {% load static %}
30
73
  {% block css %}
31
74
  <link rel="stylesheet" type="text/css" href="{% static '/css/header.css' %}">
32
75
  <link rel="stylesheet" type="text/css" href="{% static '/css/account-style.css' %}">
33
76
  {% endblock %}
77
+ {% block js %}{% endblock %}
78
+
34
79
 
35
80
 
36
81
  {% block title %}ログイン{% endblock %}
@@ -92,46 +137,6 @@
92
137
 
93
138
  ```
94
139
 
95
- ```templates/allauth/account/login.html
96
- {% load static %}<!-- static設定を読み込む -->
97
- {% load django_bootstrap5 %}
98
-
99
- <!DOCTYPE html>
100
- <html lang="ja">
101
- <head>
102
- <meta charset="UTF-8">
103
- <meta http-equiv="content-language" content="ja">
104
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
105
- <title>テスト</title>
106
- <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
107
- <link href="{% static 'vendor/bootstrap/css/bootstrap-grid.min.css' %}" rel="stylesheet">
108
- <link href="{% static 'moomin.css' %}" rel="stylesheet">
109
-
110
- {% block meta_tag %}{% endblock %}
111
- {% block css %}{% endblock %}
112
- {% bootstrap_css %}
113
- {% bootstrap_javascript %}
114
-
115
- <!--css-->
116
- <link href="{% static 'css/app.css' %}" rel="stylesheet">
117
- <link href="{% static 'css/header.css' %}" rel="stylesheet">
118
- <link href="{% static 'css/base.css' %}" rel="stylesheet">
119
- <link href="{% static 'css/queries.css' %}" rel="stylesheet">
120
-
121
- <!--JavaScript-->
122
-
123
- </head>
124
-
125
- <body class="bg-dark">
126
- {% include 'nav.html' %} <!-- nav.htmlの記述を持ってくる -->
127
- {% block contents %}{% endblock %}
128
- </body>
129
- <script src="{% static 'js/jquery-3.4.1.min.js' %}"></script>
130
- <script src="{% static 'js/bootstrap.bundle.min.js' %}"></script>
131
-
132
- </html>
133
- ```
134
-
135
140
  ### 試したこと
136
141
  accounts/loginページでテスト環境の表示されないページで検証をクリックして中のコードを確認したのですが、login.htmlのコードが入っていませんでした。
137
142
  accountsディレクトリ下にもurls.pyを作って表示されるようにしたほうが良いのでしょうか?

4

追記

2024/07/08 09:19

投稿

student
student

スコア76

test CHANGED
File without changes
test CHANGED
@@ -25,18 +25,74 @@
25
25
  ### 該当のソースコード
26
26
 
27
27
  ```project_name/urls.html
28
- from django.contrib import admin
28
+ {% extends "account/base.html" %}
29
- from django.urls import path,include
29
+ {% load static %}
30
+ {% block css %}
31
+ <link rel="stylesheet" type="text/css" href="{% static '/css/header.css' %}">
32
+ <link rel="stylesheet" type="text/css" href="{% static '/css/account-style.css' %}">
33
+ {% endblock %}
30
34
 
35
+
36
+ {% block title %}ログイン{% endblock %}
37
+
31
- urlpatterns = [
38
+ {% block content %}
39
+
40
+ <section class="container">
41
+
32
- path('admin/', admin.site.urls),
42
+ <h2>LOGIN</h2>
43
+ <form class="login" method="POST" action="{% url 'account_login' %}">
44
+ {% csrf_token %}
45
+
46
+ {% for field in form%}
47
+ <div class="account-form">
48
+ <div class="account-filed">
49
+ {% if forloop.last %}
50
+ <span class="last-field">{{ field }}</span>
51
+ <span class="login-maintain">ログイン状態を維持する</span>
33
- # 追記
52
+ {% else %}
53
+ <span class="non-last-field">{{ field }}</span>
54
+ {% endif %}
55
+ </div>
56
+
57
+ <div class="account-helptext">
58
+ {% if field.errors %}
34
- path('',include('app.urls')),
59
+ <p>{{ field.errors.0 }}</p>
60
+ {% endif %}
61
+ </div>
62
+ </div>
63
+ {% endfor%}
64
+
65
+ {% if redirect_field_value %}
66
+ <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
67
+ {% endif %}
68
+
69
+ {% if form.non_field_errors %}
70
+ <div class="non-field-error">
71
+ <ul>
72
+ {% for non_field_error in form.non_field_errors %}
35
- path('accounts/', include('allauth.urls')),
73
+ <li>{{non_field_error}}</li>
74
+ {% endfor %}
75
+ </ul>
76
+ </div>
36
- ]
77
+ {% endif %}
78
+ <div class="password-reset">
79
+ <a class="secondaryAction" href="{% url 'account_reset_password' %}"> パスワードの再設定</a>
80
+ </div>
81
+
82
+ <div class="account-grid">
83
+ <button class="btn primaryAction form-submit" type="submit">ログイン</button>
84
+ <a href="{{ signup_url }}" class="btn btn-account create-account">アカウント作成</a>
85
+ </div>
86
+
87
+ </form>
88
+
89
+ </section>
90
+
91
+ {% endblock %}
92
+
37
93
  ```
38
94
 
39
- ```templates/base.html
95
+ ```templates/allauth/account/login.html
40
96
  {% load static %}<!-- static設定を読み込む -->
41
97
  {% load django_bootstrap5 %}
42
98
 

3

追記

2024/07/08 09:14

投稿

student
student

スコア76

test CHANGED
File without changes
test CHANGED
@@ -36,69 +36,55 @@
36
36
  ]
37
37
  ```
38
38
 
39
- ```templates/allauth/account/signup.html
39
+ ```templates/base.html
40
- {% extends "account/base.html" %}
40
+ {% load static %}<!-- static設定を読み込む -->
41
- {% load static %}
41
+ {% load django_bootstrap5 %}
42
- {% block css %}
43
- <link rel="stylesheet" type="text/css" href="{% static '/css/header.css' %}">
44
- <link rel="stylesheet" type="text/css" href="{% static '/css/account-style.css' %}">
45
- {% endblock %}
46
- {% block js %}{% endblock %}
47
42
 
43
+ <!DOCTYPE html>
44
+ <html lang="ja">
45
+ <head>
46
+ <meta charset="UTF-8">
47
+ <meta http-equiv="content-language" content="ja">
48
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
49
+ <title>テスト</title>
50
+ <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
51
+ <link href="{% static 'vendor/bootstrap/css/bootstrap-grid.min.css' %}" rel="stylesheet">
52
+ <link href="{% static 'moomin.css' %}" rel="stylesheet">
53
+
54
+ {% block meta_tag %}{% endblock %}
55
+ {% block css %}{% endblock %}
56
+ {% bootstrap_css %}
57
+ {% bootstrap_javascript %}
58
+
59
+ <!--css-->
60
+ <link href="{% static 'css/app.css' %}" rel="stylesheet">
61
+ <link href="{% static 'css/header.css' %}" rel="stylesheet">
62
+ <link href="{% static 'css/base.css' %}" rel="stylesheet">
63
+ <link href="{% static 'css/queries.css' %}" rel="stylesheet">
64
+
65
+ <!--JavaScript-->
66
+
67
+ </head>
48
68
 
69
+ <body class="bg-dark">
70
+ {% include 'nav.html' %} <!-- nav.htmlの記述を持ってくる -->
71
+ {% block contents %}{% endblock %}
72
+ </body>
73
+ <script src="{% static 'js/jquery-3.4.1.min.js' %}"></script>
74
+ <script src="{% static 'js/bootstrap.bundle.min.js' %}"></script>
49
75
 
50
- {% block title %}アカウント作成{% endblock %}
51
-
52
- {% block content %}
53
-
54
- <section class="container">
55
-
56
- <h2>SIGN UP</h2>
57
- <form class="signup" id="signup_form" method="post" action="{% url 'account_signup' %}">
58
- {% csrf_token %}
59
-
60
- {% for field in form%}
61
- <div class="account-form">
62
- <div class="account-filed">
63
- <span class="non-last-field">{{ field }}</span>
64
- </div>
65
-
66
- <div class="account-helptext">
67
- {% if field.errors %}
68
- <p>{{ field.errors.0 }}</p>
69
- {% endif %}
70
- </div>
71
- </div>
72
- {% endfor%}
73
-
74
- {% if redirect_field_value %}
75
- <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
76
- {% endif %}
77
-
78
- {% if form.non_field_errors %}
79
- <div class="non-field-error">
80
- <ul>
81
- {% for non_field_error in form.non_field_errors %}
82
- <li>{{non_field_error}}</li>
83
- {% endfor %}
84
- </ul>
76
+ </html>
85
- </div>
86
- {% endif %}
87
-
88
- <div class="account-grid">
89
- <button class="primaryAction form-submit" type="submit">アカウント作成</button>
90
- <a href="{{ login_url }}" class="btn btn-account create-account">ログインに戻る</a>
91
- </div>
92
- </form>
93
- </section>
94
-
95
- {% endblock %}
96
77
  ```
97
78
 
98
79
  ### 試したこと
99
80
  accounts/loginページでテスト環境の表示されないページで検証をクリックして中のコードを確認したのですが、login.htmlのコードが入っていませんでした。
100
81
  accountsディレクトリ下にもurls.pyを作って表示されるようにしたほうが良いのでしょうか?
101
82
 
83
+
84
+ !追記!
85
+ コンソールのエラーが多かったので色々と調べて上記の{% extends "account/base.html" %}の箇所を消すとフォーム欄が表示されました。
86
+ 恐らくbase.htmlに原因があるのではないかと思いました。
87
+
102
88
  ### 補足情報(FW/ツールのバージョンなど)
103
89
  python3
104
90
  Django4

2

追記

2024/07/06 18:52

投稿

student
student

スコア76

test CHANGED
File without changes
test CHANGED
@@ -36,6 +36,65 @@
36
36
  ]
37
37
  ```
38
38
 
39
+ ```templates/allauth/account/signup.html
40
+ {% extends "account/base.html" %}
41
+ {% load static %}
42
+ {% block css %}
43
+ <link rel="stylesheet" type="text/css" href="{% static '/css/header.css' %}">
44
+ <link rel="stylesheet" type="text/css" href="{% static '/css/account-style.css' %}">
45
+ {% endblock %}
46
+ {% block js %}{% endblock %}
47
+
48
+
49
+
50
+ {% block title %}アカウント作成{% endblock %}
51
+
52
+ {% block content %}
53
+
54
+ <section class="container">
55
+
56
+ <h2>SIGN UP</h2>
57
+ <form class="signup" id="signup_form" method="post" action="{% url 'account_signup' %}">
58
+ {% csrf_token %}
59
+
60
+ {% for field in form%}
61
+ <div class="account-form">
62
+ <div class="account-filed">
63
+ <span class="non-last-field">{{ field }}</span>
64
+ </div>
65
+
66
+ <div class="account-helptext">
67
+ {% if field.errors %}
68
+ <p>{{ field.errors.0 }}</p>
69
+ {% endif %}
70
+ </div>
71
+ </div>
72
+ {% endfor%}
73
+
74
+ {% if redirect_field_value %}
75
+ <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
76
+ {% endif %}
77
+
78
+ {% if form.non_field_errors %}
79
+ <div class="non-field-error">
80
+ <ul>
81
+ {% for non_field_error in form.non_field_errors %}
82
+ <li>{{non_field_error}}</li>
83
+ {% endfor %}
84
+ </ul>
85
+ </div>
86
+ {% endif %}
87
+
88
+ <div class="account-grid">
89
+ <button class="primaryAction form-submit" type="submit">アカウント作成</button>
90
+ <a href="{{ login_url }}" class="btn btn-account create-account">ログインに戻る</a>
91
+ </div>
92
+ </form>
93
+ </section>
94
+
95
+ {% endblock %}
96
+ ```
97
+
39
98
  ### 試したこと
40
99
  accounts/loginページでテスト環境の表示されないページで検証をクリックして中のコードを確認したのですが、login.htmlのコードが入っていませんでした。
41
100
  accountsディレクトリ下にもurls.pyを作って表示されるようにしたほうが良いのでしょうか?

1

修正

2024/07/06 18:41

投稿

student
student

スコア76

test CHANGED
File without changes
test CHANGED
@@ -5,6 +5,7 @@
5
5
  [【Django】allauthのtemplatesがどこにあるのかを知りたいです。](https://teratail.com/questions/0cbxkxp4azs62q#reply-epdxdwaomjt0g6)
6
6
 
7
7
  ### 前提
8
+ ```
8
9
  templatesのファイル構成
9
10
  templates
10
11
  |-allauth
@@ -17,7 +18,7 @@
17
18
  |base.html
18
19
  |index.html
19
20
  |nav.html
20
-
21
+ ```
21
22
  ### 発生している問題・エラーメッセージ
22
23
  templatesにあるうユーザー認証ページが表示されません。
23
24