작성
·
1.1K
0
강의는 대략 도커파일 작성 쯤입니다만, hello_world를 삭제한 강의 이후쯤부터 잘못된것 같습니다.
SignUp에서 id와 pw를 입력하면,
Reverse for 'hello_world' not found. 'hello_world' is not a valid view function or pattern name.
라는 오류 메세지가 뜨네요.
url 패턴을 정의할 때, pattern name을 지정하지 않아서, url reverse 시에 해당 패턴을 찾지못한다는 오류로 알고있습니다.
어디가 틀렸을까요?
그 hello world 함수를 강좌대로 삭제한게 맞았고, 같은 코드를 작성했다고 믿었는데 저는 오류메세지가 뜨네요 ㅜㅜ
해결을 위해 커뮤니티에 'reverse'라는 키워드로 질문 검색해봤는데,
같은 오류지만 원인이 다른 것 같습니다.
https://github.com/synodical/pinterest_django 제 깃헙주소입니다
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/accounts/create/
Django Version: 3.2.5
Python Version: 3.8.2
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap4',
'accountapp',
'profileapp',
'articleapp',
'commentapp',
'projectapp',
'subscribeapp']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/views/generic/edit.py", line 172, in post
return super().post(request, *args, **kwargs)
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/views/generic/edit.py", line 142, in post
return self.form_valid(form)
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/views/generic/edit.py", line 126, in form_valid
return super().form_valid(form)
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/views/generic/edit.py", line 57, in form_valid
return HttpResponseRedirect(self.get_success_url())
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/views/generic/edit.py", line 112, in get_success_url
if self.success_url:
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/utils/functional.py", line 135, in __wrapper__
res = func(*self.__args, **self.__kw)
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/urls/base.py", line 86, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
File "/Users/LeeYeEun/venv/lib/python3.8/site-packages/django/urls/resolvers.py", line 694, in _reverse_with_prefix
raise NoReverseMatch(msg)
Exception Type: NoReverseMatch at /accounts/create/
Exception Value: Reverse for 'hello_world' not found. 'hello_world' is not a valid view function or pattern name.
답변 1
0
안녕하세요.
질문 확인했습니다.
남겨주신 깃 주소에서 코드를 확인해보니까,
AccountCreateView 에 아직 고치지 않은 부분이 있더라구요.
class AccountCreateView(CreateView):
model = User
form_class = UserCreationForm
success_url = reverse_lazy('accountapp:hello_world')
template_name = 'accountapp/create.html'
...
@method_decorator(has_ownership, 'get')
@method_decorator(has_ownership, 'post')
class AccountUpdateView(UpdateView):
model = User
context_object_name = 'target_user'
form_class = AccountUpdateForm
success_url = reverse_lazy('accountapp:hello_world')
template_name = 'accountapp/update.html'
보시게 되면, success_url 파라미터가 아직 hello_world 로 설정되어 있어서,
말씀하신 에러가 난 것으로 보여요.
해당 부분 수정해주신다면 정상적으로 구동이 될것으로 보입니다.
좋은하루 보내시구요!
감사합니다-