L
L
last72014-07-23 20:55:31
Django
last7, 2014-07-23 20:55:31

Is it correct to modify sys.path to suit the Django project structure?

I want to change the structure of my project to a similar one ( https://github.com/rdegges/django-skel ), that is, where all the applications are in the "apps" package. But I don't want to have "apps.*.", "apps.model.*" imports everywhere in the code Is it
correct to add to settings.py? That is, modify the search paths?

sys.path.append(os.path.normpath(os.path.join(BASE_DIR, 'src/apps')))

What pitfalls can be?
If you insert something in settings.py or somewhere else?
PS If you have your own developments in the structure of large Django projects, please share.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sakuradaj, 2014-07-24
@sakuradaj

In one of my projects, I ventured to do this, but a little differently:

├── src
│   ├── main_app_name
│   ├── first_app
│   ├── second_app
│   └── third_app
├── manage.py
├── requirements.txt

The src folder contains Django applications, including the main one.
I add this folder to sys.path in the files manage.py and wsgi.py
There are no problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question