質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,7 +19,121 @@
|
|
19
19
|
```
|
20
20
|
に存在しています。
|
21
21
|
|
22
|
-
|
22
|
+
### エラー
|
23
|
+
```
|
24
|
+
Traceback Switch to copy-and-paste view
|
25
|
+
/home/ec2-user/.local/lib/python3.8/site-packages/django/core/handlers/exception.py, line 55, in inner
|
26
|
+
return inner
|
27
|
+
else:
|
28
|
+
@wraps(get_response)
|
29
|
+
def inner(request):
|
30
|
+
try:
|
31
|
+
response = get_response(request) …
|
32
|
+
except Exception as exc:
|
33
|
+
response = response_for_exception(request, exc)
|
34
|
+
return response
|
35
|
+
return inner
|
36
|
+
Local vars
|
37
|
+
Variable Value
|
38
|
+
exc
|
39
|
+
TemplateDoesNotExist('accounts/profile_edit.html')
|
40
|
+
get_response
|
41
|
+
<bound method BaseHandler._get_response of <django.core.handlers.wsgi.WSGIHandler object at 0x7fde9409ad30>>
|
42
|
+
request
|
43
|
+
<WSGIRequest: GET '/accounts/profile_edit/'>
|
44
|
+
/home/ec2-user/.local/lib/python3.8/site-packages/django/core/handlers/base.py, line 197, in _get_response
|
45
|
+
if response is None:
|
46
|
+
wrapped_callback = self.make_view_atomic(callback)
|
47
|
+
# If it is an asynchronous view, run it in a subthread.
|
48
|
+
if iscoroutinefunction(wrapped_callback):
|
49
|
+
wrapped_callback = async_to_sync(wrapped_callback)
|
50
|
+
try:
|
51
|
+
response = wrapped_callback(request, *callback_args, **callback_kwargs) …
|
52
|
+
except Exception as e:
|
53
|
+
response = self.process_exception_by_middleware(e, request)
|
54
|
+
if response is None:
|
55
|
+
raise
|
56
|
+
# Complain if the view returned None (a common error).
|
57
|
+
Local vars
|
58
|
+
Variable Value
|
59
|
+
callback
|
60
|
+
<function View.as_view.<locals>.view at 0x7fde92cc6700>
|
61
|
+
callback_args
|
62
|
+
()
|
63
|
+
callback_kwargs
|
64
|
+
{}
|
65
|
+
request
|
66
|
+
<WSGIRequest: GET '/accounts/profile_edit/'>
|
67
|
+
response
|
68
|
+
None
|
69
|
+
self
|
70
|
+
<django.core.handlers.wsgi.WSGIHandler object at 0x7fde9409ad30>
|
71
|
+
wrapped_callback
|
72
|
+
<function View.as_view.<locals>.view at 0x7fde92cc6700>
|
73
|
+
/home/ec2-user/.local/lib/python3.8/site-packages/django/views/generic/base.py, line 104, in view
|
74
|
+
self = cls(**initkwargs)
|
75
|
+
self.setup(request, *args, **kwargs)
|
76
|
+
if not hasattr(self, "request"):
|
77
|
+
raise AttributeError(
|
78
|
+
"%s instance has no 'request' attribute. Did you override "
|
79
|
+
"setup() and forget to call super()?" % cls.__name__
|
80
|
+
)
|
81
|
+
return self.dispatch(request, *args, **kwargs) …
|
82
|
+
view.view_class = cls
|
83
|
+
view.view_initkwargs = initkwargs
|
84
|
+
# __name__ and __qualname__ are intentionally left unchanged as
|
85
|
+
# view_class should be used to robustly determine the name of the view
|
86
|
+
Local vars
|
87
|
+
/home/ec2-user/.local/lib/python3.8/site-packages/django/contrib/auth/mixins.py, line 73, in dispatch
|
88
|
+
class LoginRequiredMixin(AccessMixin):
|
89
|
+
"""Verify that the current user is authenticated."""
|
90
|
+
def dispatch(self, request, *args, **kwargs):
|
91
|
+
if not request.user.is_authenticated:
|
92
|
+
return self.handle_no_permission()
|
93
|
+
return super().dispatch(request, *args, **kwargs) …
|
94
|
+
class PermissionRequiredMixin(AccessMixin):
|
95
|
+
"""Verify that the current user has all specified permissions."""
|
96
|
+
permission_required = None
|
97
|
+
Local vars
|
98
|
+
/home/ec2-user/.local/lib/python3.8/site-packages/django/views/generic/base.py, line 143, in dispatch
|
99
|
+
# request method isn't on the approved list.
|
100
|
+
if request.method.lower() in self.http_method_names:
|
101
|
+
handler = getattr(
|
102
|
+
self, request.method.lower(), self.http_method_not_allowed
|
103
|
+
)
|
104
|
+
else:
|
105
|
+
handler = self.http_method_not_allowed
|
106
|
+
return handler(request, *args, **kwargs) …
|
107
|
+
def http_method_not_allowed(self, request, *args, **kwargs):
|
108
|
+
logger.warning(
|
109
|
+
"Method Not Allowed (%s): %s",
|
110
|
+
request.method,
|
111
|
+
request.path,
|
112
|
+
Local vars
|
113
|
+
/home/ec2-user/environment/agent_test/accounts/views.py, line 30, in get
|
114
|
+
return render(request, 'accounts/profile_edit.html', { …
|
115
|
+
Local vars
|
116
|
+
/home/ec2-user/.local/lib/python3.8/site-packages/django/shortcuts.py, line 24, in render
|
117
|
+
content = loader.render_to_string(template_name, context, request, using=using) …
|
118
|
+
Local vars
|
119
|
+
/home/ec2-user/.local/lib/python3.8/site-packages/django/template/loader.py, line 61, in render_to_string
|
120
|
+
template = get_template(template_name, using=using) …
|
121
|
+
Local vars
|
122
|
+
/home/ec2-user/.local/lib/python3.8/site-packages/django/template/loader.py, line 19, in get_template
|
123
|
+
raise TemplateDoesNotExist(template_name, chain=chain) …
|
124
|
+
Local vars
|
125
|
+
Variable Value
|
126
|
+
chain
|
127
|
+
[TemplateDoesNotExist('accounts/profile_edit.html')]
|
128
|
+
engine
|
129
|
+
<django.template.backends.django.DjangoTemplates object at 0x7fde93771310>
|
130
|
+
engines
|
131
|
+
[<django.template.backends.django.DjangoTemplates object at 0x7fde93771310>]
|
132
|
+
template_name
|
133
|
+
'accounts/profile_edit.html'
|
134
|
+
using
|
135
|
+
None
|
136
|
+
```
|
23
137
|
|
24
138
|
### 該当のソースコード
|
25
139
|
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,6 +8,9 @@
|
|
8
8
|
ちなみにaccounts/profile_edit.htmlは
|
9
9
|
```
|
10
10
|
Project
|
11
|
+
|-Project
|
12
|
+
|-accounts
|
13
|
+
|-app
|
11
14
|
|-templates
|
12
15
|
|-allauth
|
13
16
|
|-account
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -71,6 +71,49 @@
|
|
71
71
|
})
|
72
72
|
```
|
73
73
|
|
74
|
+
```accounts/urls.py
|
75
|
+
from django.urls import path
|
76
|
+
from accounts import views
|
77
|
+
app_name = 'accounts'
|
78
|
+
urlpatterns = [
|
79
|
+
path('profile/', views.Show.as_view(), name='profile'),
|
80
|
+
path('profile_edit/', views.Edit.as_view(), name='profile_edit'),
|
81
|
+
]
|
82
|
+
```
|
83
|
+
|
84
|
+
```project/urls.py
|
85
|
+
from django.contrib import admin
|
86
|
+
from django.urls import path,include
|
87
|
+
|
88
|
+
urlpatterns = [
|
89
|
+
path('admin/', admin.site.urls),
|
90
|
+
# 追記
|
91
|
+
path('',include('app.urls')),
|
92
|
+
path('accounts/', include('allauth.urls')),
|
93
|
+
path('accounts/', include('accounts.urls')),
|
94
|
+
]
|
95
|
+
```
|
96
|
+
|
97
|
+
```settings.py
|
98
|
+
TEMPLATES = [
|
99
|
+
{
|
100
|
+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
101
|
+
'DIRS': [os.path.join(BASE_DIR, 'templates'),
|
102
|
+
os.path.join(BASE_DIR, 'templates', 'allauth')
|
103
|
+
],
|
104
|
+
'APP_DIRS': True,
|
105
|
+
'OPTIONS': {
|
106
|
+
'context_processors': [
|
107
|
+
'django.template.context_processors.debug',
|
108
|
+
'django.template.context_processors.request',
|
109
|
+
'django.contrib.auth.context_processors.auth',
|
110
|
+
'django.contrib.messages.context_processors.messages',
|
111
|
+
],
|
112
|
+
},
|
113
|
+
},
|
114
|
+
]
|
115
|
+
```
|
116
|
+
|
74
117
|
### 試したこと・調べたこと
|
75
118
|
- [x] teratailやGoogle等で検索した
|
76
119
|
- [ ] ソースコードを自分なりに変更した
|