Closed tango4567 closed 2 years ago
Well I used return render(request, 'register.html')
instead of return redirect('register')
so it's solved my problem temporary but I'm keep looking on it. Even after registering function properly in urls.py
Some interesting conversation I found mention below.
Solution: Well I missed to mention function name in urlpatterns arrays at urls.py from django.urls import path from . import views
NoReverseMatch at /register
Request Method: | POST -- | -- http://127.0.0.1:8000/register 4.1 NoReverseMatch Reverse for 'register' not found. 'register' is not a valid view function or pattern name. C:\Users\TarunMahajan\.virtualenvs\pracPy-b7vdO4P5\lib\site-packages\django\urls\resolvers.py, line 803, in _reverse_with_prefix website.views.register C:\Users\TarunMahajan\.virtualenvs\pracPy-b7vdO4P5\Scripts\python.exe 3.10.4 ['C:\\Users\\TarunMahajan\\djangoProjects\\pracPy', 'C:\\Python310\\python310.zip', 'C:\\Python310\\DLLs', 'C:\\Python310\\lib', 'C:\\Python310', 'C:\\Users\\TarunMahajan\\.virtualenvs\\pracPy-b7vdO4P5', 'C:\\Users\\TarunMahajan\\.virtualenvs\\pracPy-b7vdO4P5\\lib\\site-packages'] Mon, 22 Aug 2022 01:45:33 +0000Log
Environment: Request Method: POST Request URL: http://127.0.0.1:8000/register Django Version: 4.1 Python Version: 3.10.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'website'] 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 "C:\Users\TarunMahajan\\.virtualenvs\pracPy-b7vdO4P5\lib\site-packages\django\core\handlers\exception.py", line 55, in inner response = get_response(request) File "C:\Users\TarunMahajan\\.virtualenvs\pracPy-b7vdO4P5\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\TarunMahajan\\djangoProjects\pracPy\website\views.py", line 83, in register return redirect('register') File "C:\Users\TarunMahajan\\.virtualenvs\pracPy-b7vdO4P5\lib\site-packages\django\shortcuts.py", line 48, in redirect return redirect_class(resolve_url(to, *args, **kwargs)) File "C:\Users\TarunMahajan\\.virtualenvs\pracPy-b7vdO4P5\lib\site-packages\django\shortcuts.py", line 145, in resolve_url return reverse(to, args=args, kwargs=kwargs) File "C:\Users\TarunMahajan\\.virtualenvs\pracPy-b7vdO4P5\lib\site-packages\django\urls\base.py", line 88, in reverse return resolver._reverse_with_prefix(view, prefix, *args, **kwargs) File "C:\Users\TarunMahajan\\.virtualenvs\pracPy-b7vdO4P5\lib\site-packages\django\urls\resolvers.py", line 803, in _reverse_with_prefix raise NoReverseMatch(msg) Exception Type: NoReverseMatch at /register Exception Value: Reverse for 'register' not found. 'register' is not a valid view function or pattern name.Here we can see register function is registered
Using the URLconf defined in tarunmahajan.urls, Django tried these URL patterns, in this order: