Issue
I have urls.py in project.
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path("", include("core.urls")),
path("user/", include("userauths.urls"))
> ]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Then, I create an app named "userauths". In my app I have userauths/urls.py:
from django.urls import path
from userauths import views as auth_views
app_name = "userauths"
urlpatterns = [
path("sign-up/", auth_views.register_view, name="sign-up"),
path("sign-in/", auth_views.login_view, name="sign-in"),
path("sign-out/", auth_views.logout_view, name="sign-out"),
]
In index.html file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Index Page</title>
</head>
<body>
<a href="{% url 'userauths: sign-in' %}">Sign-in</a>
</body>
</html>
But when runserver django, it display errors. I don't know this url Sign-in how to wrong?
Reverse for ' sign-in' not found. ' sign-in' is not a valid view function or pattern name.
Solution
I think that your problem is the space between : and sign-in, in the message, it says ' sign-in' not found
with the space; try to remove it.
Another option, check the current URLs with django-extensions, you can add this dependency and exec ./manage.py show_urls
and see all the URLs with the name to copy directly.
Answered By - FedeG
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.