Home > Blockchain >  django : 'app name' is not a registered namespace
django : 'app name' is not a registered namespace

Time:12-22

i have a "NoReverseMatch" error, how can i slove this i don't understand-

Project_name/urls.py

path('orders/',include('orders.urls')),

ordres/urls.py

from .views import chack_out
path('chack_out/', chack_out, name='chack_out')

ordres/views.py

def chack_out(request):
    .....

product(anther app name)/templates/product/cart.html

<form action="{% url 'orders:chack_out' %}" method="POST">
     {% csrf_token %}

error page

enter image description here

CodePudding user response:

Add the desired namespace to the urls.py file:

path('orders/', include('orders.urls', namespace='orders')),

or set the app_name attribute inside the ordres/urls.py file:

from .views import chack_out

app_name = 'orders'
urlpatterns = [
    path('chack_out/', chack_out, name='chack_out')
]

Check out the documentation for URL namespaces.

  • Related