NoReverseMatch at /signup/
Reverse for 'adduser' not found. 'adduser' is not a valid view function or pattern name.
<form method="post" action="{% url 'adduser' %}">
{% csrf_token %}
<div class="form-outline mb-4">
<input type="text" id="form3Example1cg" class="form-control form-control-lg" name="username" required/>
<label class="form-label" for="form3Example1cg">Your Name</label>
</div>
<div class="form-outline mb-4">
<input type="email" id="form3Example3cg" class="form-control form-control-lg" name="email" required/>
<label class="form-label" for="form3Example3cg">Your Email</label>
</div>
<div class="form-outline mb-4">
<input type="password" id="form3Example4cg" class="form-control form-control-lg" name="password" required/>
<label class="form-label" for="form3Example4cg">Password</label>
</div>
<div class="form-outline mb-4">
<input type="password" id="form3Example4cdg" class="form-control form-control-lg" required/>
<label class="form-label" for="form3Example4cdg">Repeat your password</label>
</div>
<div class="d-flex justify-content-center">
<button type="button"
class="btn btn-success btn-block btn-lg gradient-custom-4 text-body">Register</button>
</div>
<p class="text-center mt-5 mb-0 ">Have already an account? <a href="{% url 'login' %}"
class="fw-bold text-white-50"><u>Login here</u></a></p>
</form>
def adduser(request):
if request.method == 'POST':
form = UserRegistratration(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data["username"]
else:
form = UserRegistratration()
return redirect("home")
return render(request, "registration/signup.html")
urlpatterns = [
path('', views.V_home, name="home"),
path('login/', views.V_login, name="login"),
path('signup/', views.adduser, name="signup")`Preformatted text`
]
Please show your urls.py file where you have that name defined for a view.
```from django.urls import path
from . import views
# Crear urls
app urls
urlpatterns = [
path('', views.V_home, name="home"),
path('login/', views.V_login, name="login"),
path('signup/', views.adduser, name="signup"),
path('mainapp/', views.V_mainapp, name="mainapp"),
path('stats/', views.V_stats, name="stats")
]
site urls
urlpatterns = [
path('admin/', admin.site.urls),
path('', include("MainApp.urls")),
path('accounts/', include("django.contrib.auth.urls")),
]
1 Like
You don’t have a url with the name adduser
.
I thought you put the name of the function
Tanks
From the docs at Built-in template tags and filters | Django documentation | Django
The first argument is a URL pattern name.