0

I would like to change the layout of standard django project and I also run django with virtual env. How can I do it? Current project structure looks like this:

app1
  - __init.py__
  - admin.py
  - apps.py
  - models.py
  - tests.py
  - views.py
mysite
  - __init.py
  - asgi.py
  - settings.py
  - urls.py
  - wsgi.py
db.sqlite3
manage.py
.gitignore
requirements.txt

I would like to move these files into separate folder called src and leave some non-django files outside of the structure (things like gitignore, requirements, etc.), so the directory looks like this. Btw, if I move the files into src, django outputs 'No module named src'. Probably, I'm missing some settings.py to fix the path, but I can't figure out which one.

src
  app1
      - __init.py__
      - admin.py
      - apps.py
      - models.py
      - tests.py
      - views.py
    mysite
      - __init.py
      - asgi.py
      - settings.py
      - urls.py
      - wsgi.py
    db.sqlite3
    manage.py
.gitignore
requirements.txt
  • what's the problem? did you do that and faced any errors? – Mohammad Jafari Aug 21 '20 at 20:06
  • Yes, I tried to move the files into src, but django started giving errors "No module named src". I tried to replace entry points in settings.py for mysite related paths, but it did not resolve the issue –  Aug 21 '20 at 20:42
  • What did you do exactly? Where did you see the error? You only need to create a folder `src` and simply CUT everything into it. – Mohammad Jafari Aug 21 '20 at 20:47
  • I would recommend you create you project like so: `mkdir src; cd src; django-admin projectstart myproject` – Red Cricket Aug 21 '20 at 20:48
  • That's what I did. I simply cut the files, leaving gitignore and requirements, and pasted them into src. When I try to runserver, it says No module named src. –  Aug 21 '20 at 20:54
  • that because django thinks src is project directory. You need to move your project directory into the src directory. – Red Cricket Aug 21 '20 at 20:55

0 Answers0