Django: Do I really need apps.py inside an app?

Viewed 2492

When creating an app with python manage.py startapp myapp, it automatically creates an apps.py file.

from django.apps import AppConfig


class MyappConfig(AppConfig):
    name = 'myapp'

When I removed it, everything seems to work as before (at least my tests all passed). Is it a bad practice to remove these kind of files from the apps? Should we keep them to avoid side effects?

1 Answers

The recommended approach in Django is to use the app config in your INSTALLED_APPS:

INSTALLED_APPS = [
    'myapp.apps.MyappConfig',
    ...
]

If you do this, then the apps.py file is required.

However, if you do not customize the app config at all, then it is possible to remove the apps.py if you use the app name in INSTALLED_APPS instead:

INSTALLED_APPS = [
    'myapp',
    ...
]
Related