Search code examples
pythondjangopython-3.xdjango-settings

No module named installing Django App correctly


I've recently started a Django project using 1.10+ and it is not clear to me how to 'correctly' reference the app from the project settings without specifying the full path.

I've read the Django Application Guide, but I'm still somewhat confused.

Given the structure below, how do I 'install' the users app 'correctly so that it's reusable later on.

enter image description here

This is my apps/user/app.py

from django.apps import AppConfig


class UserConfig(AppConfig):
    name = 'users'
    verbose_name = "User Catalogue"

In settings.py for the project I would like to do the following...

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # apps
    'apps.users',

]

I have also tried the following: apps.users.apps.UserConfig but get a No module named 'users' and even if it did work it's not as clean as using 'users'.


Solution

  • i think you need to add into apps.__init__.py

    from users.apps import UserConfig
    

    or

    default_app_config = 'users.apps.UserConfig'