Fixing Django Error – ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported.

Django Error – ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported is an error which occurs when you forget to specify app_name in your urls.py file and for other reasons.

In today’s blog post I am going to present an annoying and confusing python error and explain why this error is taking place and how to fix it, with a set of possible fixes.

Exploring the Django Error – ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported.

This is an error which occurs when you 

Beware of mixing between errors. Double check if the error message looks like the error message bellow, then continue.

                                                                       #
Specifying a namespace in include() without providing an app_name is not supported. 
Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.
                                                                       #

Solution 1 : specify app_name in your urls.py

In a lot of cases, the error occurs when you forget to specify app_name in your urls.py.

Open the file urls.py. Then, Directly after the imports in your file, add the following line of code.

                                                                       #
app_name = 'yourapp'
                                                                       #

The same name you chose for app_name should be your namespace name at the project level url

                                                                       #
path('',include('myapp.urls'), namespace= 'yourapp')
                                                                       #

This is all you have to do, now run your code and see if the error persist.

If you still have the error, please try the method bellow.

Solution 2 : Correctly use include()

In many case the error might occur when you use include the wrong way and add the wrong parameters to it or maybe make a syntax error.

For example using the line bellow, will cause the error.

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

The correct way to use include is this.

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

I hope the methods above solved your problem, consider donating to our Kofi account and good luck with your coding projects.

Summing-up : 

Thank you for reading, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/