looking for some solutions? You are welcome.

SOLVED: Reverse for '

Ayo -:

I am trying to create a user account and all is well when I use the signup view and form to sign up on the signup html page below is some info but I get this error

NoReverseMatch at /signup/

Reverse for '' not found. '' is not a valid view function or pattern name. Request Method: POST Request URL: http://127.0.0.1:8000/signup/ Django Version: 2.1.7 Exception Type: NoReverseMatch Exception Value:
Reverse for '' not found. '' is not a valid view function or pattern name. Exception Location: C:\WINDOWS\system32\dev\pastebinclonedirectory\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 622 Python Executable: C:\WINDOWS\system32\dev\pastebinclonedirectory\Scripts\python.exe Python Version: 3.6.8 Python Path:
['C:\WINDOWS\system32\dev\pastebinclonedirectory\pastebin', 'C:\WINDOWS\system32\dev\pastebinclonedirectory\Scripts\python36.zip', 'C:\WINDOWS\system32\dev\pastebinclonedirectory\DLLs', 'C:\WINDOWS\system32\dev\pastebinclonedirectory\lib', 'C:\WINDOWS\system32\dev\pastebinclonedirectory\Scripts', 'c:\users\aadeo\appdata\local\programs\python\python36\Lib', 'c:\users\aadeo\appdata\local\programs\python\python36\DLLs', 'C:\WINDOWS\system32\dev\pastebinclonedirectory', 'C:\WINDOWS\system32\dev\pastebinclonedirectory\lib\site-packages'] Server time: Wed, 13 Mar 2019 06:46:57 +0000

View.py

def signup(request):
if request.method == 'POST':
    form = UserRegisterForm(request.POST)
    if form.is_valid():
        form.save()
        username = form.cleaned_data.get('username')
        raw_password = form.cleaned_data.get('password1')
        user = authenticate(username=username, password=raw_password)
        login(request, user)
        return redirect(request,'app/index.html')
else:
    form = UserRegisterForm()
return render(request, 'app/signup.html', {'form': form})

forms.py

from django import forms from .models import Post from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User

class Userpostform(forms.ModelForm): class Meta: model = Post fields = ('title','content','private',)

class Visitorpostform(forms.ModelForm): class Meta: model = Post fields = ('title','content')

URLS.PY in apps folder

path('',views.home,name='home'),
path('accounts/', include('django.contrib.auth.urls'),name='login'),
path('signup/',views.signup,name='signup'),
path('accounts/profile/',views.profile,name='profile'),
path('logout',views.logout_view,name='logout'),
path('userpostnew', views.userpostnew, name='userpostnew'),
path('visitorpostnew', views.visitorpostnew, name='visitorpostnew'),



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent