DEV Community

Cover image for Two most common cause of "Django Import Error: No module named <appname>" in Django.

Posted on

Two most common cause of "Django Import Error: No module named <appname>" in Django.

Every django developer has experience of facing this issue. It is one of the most common errors you will face when running your first migration. This error can also produce other errors such as "TemplateDoesNotExist".

In this article we will see two most common reasons that cause Django Import Error: No module named

1. Forgot to put app name to installed_apps list?

The most common mistake that beginners make is that they forget to list their apps in INSTALLED_APPS which is present in the file.

Therefore, please make sure that your app is listed in the INSTALLED_APPS. Example:
Suppose, I have a newly started app called users within a project named polls project then I would navigate to pollsproject/ and will search for INSTALLED_APPS and will append 'users' or 'users.apps.UsersConfig' to it.

   'users.apps.UsersConfig', # added users app here
Enter fullscreen mode Exit fullscreen mode

This is the most common solution for TemplateDoesNotExist error as well so make sure you have not committed this mistake.

Now, let's look at another most common mistake that a beginner makes which results in this error.

2. App is not in the root directory of your project.

If you have listed your apps inside INSTALLED_APPS but still you are facing the *Django Import Error: No module named * error then it might be due to django could not find your app within the root directory.

Your apps can be place anywhere, but Django by default starts to search app from the project's root directory and if it does not find the app there then it will throw the same ImportError error.

Therefore, please make sure that your app is located in the same directory where file is located. For example, for a random project named pollsproject, I have created an app called users, then the whole tree structure of my project would look like:

├── env/
├── pollsproject/
│   ├── pollsproject/
│   │   ├──
│   │   ├──
│   │   ├──
│   │   ├──
│   │   └──
│   ├── users/
│   │   ├── migrations/
│   │   ├──
│   │   ├──
│   │   ├──
│   │   ├──
│   │   ├──
│   │   └──
│   ├── db.sqlite3
│   └──
├── .gitignore
├── requirements.txt
Enter fullscreen mode Exit fullscreen mode

The main cause of this problem is that when you start a fresh project and then you start an app using the django-admin command from the same location from where you run the startproject command. This will create an app outside the project's root directory. Therefore, to avoid this issue use python startapp instead of "django-admin startapp or make sure you’re in the same directory as

The good news is that Django's apps are "Pluggable" therefore, you can just move your app to the directory same as and it should work.

Let me know if none of these two worked for you, I will be more than glad to help you.

Happy Coding 🧡

Top comments (1)

imyourpartner profile image
Yes, I'm you partner • Edited

how do I work the applications within a directory at the same level of the django project?


To maintain an order, I put the applications inside a folder called 'Apps' in the root directory

from django.apps import AppConfig

class AplicacionConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Apps.Aplicacion1'



'ModuleNotFoundError: No module named 'Aplicacion1'

How to fix it?