close

[Solved] ImproperlyConfiguredError about app_name when using namespace in include()

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ImproperlyConfiguredError about app_name when using namespace in include() in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ImproperlyConfiguredError about app_name when using namespace in include() Error Occurs?

Today I get the following error ImproperlyConfiguredError about app_name when using namespace in include() in python.

How To Solve ImproperlyConfiguredError about app_name when using namespace in include() Error ?

  1. How To Solve ImproperlyConfiguredError about app_name when using namespace in include() Error ?

    To Solve ImproperlyConfiguredError about app_name when using namespace in include() Error Django 2.0 you should specify app_name in your urls.py, is not necessary to specify app_name argument on include.

  2. ImproperlyConfiguredError about app_name when using namespace in include()

    To Solve ImproperlyConfiguredError about app_name when using namespace in include() Error Django 2.0 you should specify app_name in your urls.py, is not necessary to specify app_name argument on include.

Solution 1

Check the docs for include here.

What you’ve done is not an acceptable way of passing parameters to include. You could do:

url(r'^reviews/', include(('reviews.urls', 'reviews'), namespace='reviews')),

Solution 2

Django 2.0 you should specify app_name in your urls.py, is not necessary to specify app_name argument on include.

Main Url file.

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('', include('apps.main.urls')),
    path('admin/', admin.site.urls),
]

Included Url.

from django.urls import path
from . import views

app_name = 'main_app'

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

Then use use in template as

<a href="{% url main_app:index' %}"> link </a>

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read