Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError at / 'str' object is not a mapping in django template

Tags:

I am trying to set up links inside a tags, and when I do this procedure as seen in the code, it gives me the error:

TypeError at / 'str' object is not a mapping

It use to work fine but then decided not to

template code:

<a class="item" href="{% url 'home' %}"> 

urls code:

urlpatterns = [   path('admin/', include('admin_llda.urls') ),   path('about/', views.about, name = 'about'),   path('dashboard/',views.dashboard, name = 'dashboard'),   path('',views.homepage, name = 'home')    ] 
like image 513
Ivan De leon Avatar asked Jan 04 '19 11:01

Ivan De leon


1 Answers

Check that you have properly named the name kwarg in your urls file. It's a keyword argument, not an argument. So you should type the keyword and the value.

For example your current urlpatterns list in one of your installed apps urls.py file looks like this:

    urlpatterns = [        path('', views.index, 'index'),        path('like/', views.like, 'like')     ] 

You should check if you have missed the name kwarg. The above code should be changed to:

    urlpatterns = [         path('', views.index, name='index'),         path('like/', views.like, name='like')     ] 

If you want to find it faster, you can comment each app's url inclusion, in the your_project/urls.py file. When the error is gone, it means that you should check the commented app urls.py file.

like image 199
purvi gupta Avatar answered Oct 03 '22 09:10

purvi gupta