Try to search your question here, if you can't find : Ask Any Question Now ?

Django dev server not recognizing new files after directory modification

HomeCategory: stackoverflowDjango dev server not recognizing new files after directory modification
Avatarjulie asked 2 weeks ago

I have a Django project with 2 apps and was writing some functions in a utils.py file in one of the apps. I wanted to break this up into two separate files in their own subdirectory so I created a new directory ‘utils’ a level below the app directory and placed the two utils1.py and utils2.py files in there.

I had some issues with importing something from the other app so I ended up scrapping this idea and moving everything back into one file in the base directory of the original app, exactly like it was before. Now when I runserver it is not picking up any new files that are created within apps. Not just the ones that I recreated but any new files. Files that were created prior to the change are running just fine.

So, in summary new utils.py files that I recreated in the app directory are not running when the dev server is started, and when I try to run one of them manually they run like any other python file, but imports from other locations in the project are not being recognized.

No other changes were made and new files were running perfectly fine before the directory changes.

After the changes:

├── app1
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   ├── models.py
│   ├── permissions.py
│   ├── serializers.py
│   ├── tests.py
│   ├── urls.py
│   ├── utils.py
│   └── views.py
├── manage.py
├── project
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── app2
    ├── __init__.py
    ├── admin.py
    ├── apps.py
    ├── utilities        <--- added
        ├── util1.py
        └── util2.py
    ├── migrations
    ├── models.py
    ├── serializers.py
    ├── tests.py
    ├── urls.py
    └── views.py

After reverting back to previous structure (not working):

├── app1               <--- new files created here aren't running
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   ├── models.py
│   ├── permissions.py
│   ├── serializers.py
│   ├── tests.py
│   ├── urls.py
│   ├── utils.py
│   └── views.py
├── manage.py
├── project
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── app2                <--- new files created here aren't running
    ├── __init__.py
    ├── admin.py
    ├── apps.py
    ├── util1.py        <--- moved back into app directory
    ├── migrations
    ├── models.py
    ├── util2.py        <--- moved back into app directory
    ├── serializers.py
    ├── tests.py
    ├── urls.py
    └── views.py
1 Answers
Best Answer
Avatarnaveen answered 2 weeks ago
Your Answer

6 + 17 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com