Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

django.urls.exceptions.NoReverseMatch at /home/

I have problem when I visit localhost:8000/home:

Powershell: django.urls.exceptions.NoReverseMatch: Reverse for ‘register’ not found. ‘register’ is not a valid view function or pattern name.

html:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<section>
    <nav class="navbar navbar-expand-lg bg-dark navbar-dark ">
      <!-- Container wrapper -->
      <div class="container-fluid justify-content-center">
        <!-- Navbar brand -->
        <a class="navbar-brand" href="{% url 'home_page' %}"> Turbine Power Web</a>

          <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ms-auto">
                {% if user.is_authenticated %}
                    <li class="nav-item"><a class="nav-link" href="{% url 'accounts:logout' %}">Logout</a></li>
                    <li class="nav-item"><a class="nav-link" href="{% url 'accounts:password_change' %}">Change Password</a></li>
                {% else %}
                    <li class="nav-item"><a class="nav-link" href="{% url 'accounts:login' %}">Login</a></li>
                    <li class="nav-item"><a class="nav-link" href="{% url 'accounts:user-registration' %}">Register</a></li>
                {% endif %}
                    <li class="nav-item"><a class="nav-link" href="">Turbine Models</a></li>
                    <li class="nav-item"><a class="nav-link" href="">Author</a></li>
                {% if user.is_company %}
                    <li class="nav-item"><a class="nav-link" href="">My Models</a></li>
                {% endif %}
                    <li class="nav-item"> Hello, {{ user.username|default:'Guest' }} </li>
            </ul>
        </div>
      </div>
    </nav>
    <!-- Navbar -->
</section>

views.py

def home_page(request):
    return render(request, 'turbineweb/home_page.html')

project urls.py

    urlpatterns = [
        path('admin/', admin.site.urls),
        path('', include('accounts.urls', namespace='accounts')),
        path('', include('turbineweb.urls')),

accounts urls.py

app_name = 'accounts'

urlpatterns = [
    path('login/', CustomLoginView.as_view(redirect_authenticated_user=True, template_name='accounts/login.html',
                                           authentication_form=LoginForm), name='login'),
    path('logout/', auth_views.LogoutView.as_view(template_name='accounts/logout.html'), name='logout'),
    path('registration/', RegisterView.as_view(), name='users-registration'),
    path('password-change/', ChangePasswordView.as_view(), name='password_change'),
    path('password_reset/', auth_views.PasswordResetView.as_view(), name='password_reset'),
    path('password_reset/done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'),
    path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
    path('reset/done/', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'),
]

turbineweb urls.py

app_name = 'turbineweb'

urlpatterns = [
    path('home/', views.home_page, name='home_page'),
]

Error:
enter image description here

>Solution :

You made a typo, it is users-registration and not user-registration :

<li class="nav-item"><a class="nav-link" href="{% url 'accounts:users-registration' %}">Register</a></li>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading