Unable to import apps from settings.py's INSTALLED_APPS list

710 views Asked by At

I'm hitting an error when running makemigrations, and it seems to be related to my INSTALLED_APPS list.

Here is a screenshot of my project: project overview

and here is the error: error

I've also attempted to use the following strings in the INSTALLED_APPS list, but I got the same error:

    '.api.apps.ApiConfig',
    '.pizzas.apps.PizzasConfig',

The classes ApiConfig and PizzaConfig both follow this structure in their respective apps.py files:

from django.apps import AppConfig


class PizzasConfig(AppConfig):
    name = 'pizzas'

Does anyone have any ideas as to what I could be missing here?

2

There are 2 answers

0
GabrielDS On

In some cases when you make a circular import between two or more apps (could be on models, views, any place) the django can't import propely when startup and shows this error.

Try comment all the code from the views.py in api and restart the project to see if works.

1
itismoej On

This happened to me when I had created an application with name t. However, it resolved when I used configs for registering it inside installed apps.

I believe you have a typo in the config names. An extra dot . at the beginning.

Try this one.

INSTALLED_APPS = [
    ...
    'api.apps.ApiConfig',
    'pizzas.apps.PizzasConfig',
]