Home > OS >  No module named 'globals'
No module named 'globals'

Time:12-06

I have a folder that has a Django Framework in it. I try to call files that are outside of this folder but I get the following error: No module named 'globals'

This path folder: api_yahoo_finance/yahoo/api_yahoo/views And in the views file, I try to use the file that exists outside this folder. (Outside of api_yahoo)

I tried to read on the internet and understand what the problem is, I saw comments that said to add a init file, I added it but it didn't help.

**

  • It is important to note, the package is a local package, I created it.

**

CodePudding user response:

According to the Django documentation, your project directory should be like this:

mysite/
    mysite/
        __init__.py
        settings.py
        urls.py
        asgi.py
        wsgi.py
    first_app/
        migrations/
            __init__.py
        __init__.py
        admin.py
        apps.py
        models.py
        tests.py
        views.py
    venv/
    manage.py
 

You should install your packages in your virtual environment. See more in Django documentation: https://docs.djangoproject.com/en/4.1/intro/tutorial01/

CodePudding user response:

You have to install the package before you can use it in your code. Install it using pip install globals and try to run the program again.

  • Related