0

I'm fairly new to Django and a bit confused about venvs and the file structure. I'm using VSCode to create all of this.

projectname?/
    .vs/
        ....
    .vscode/
        ....
    myproject/        #1
        myprojectapps?/
        manage.py
    myvenv/           #2
        myproject/
            Include/
            Lib/
            Scripts/
            myprojectapps?/
            manage.py

I create a top folder and point VSCode to it. I then create a new venv in this folder (#2).

Where exactly do I then create a new project? Inside my venv or inside my "root" folder?

If I create it in the root folder, will that use my OS Python installation instead of the venv, or is VSCode smart enough to use the venv that I created, if I select it from the dropdown?

Do I create new "apps" in the 'myproject' folders, or in the 'myprojectapps?' folders?

EInherjar
  • 339
  • 6
  • 17

2 Answers2

1

You'r folder structure is ok. you can have myenv in the same root folder.

Note:- mvenv is a place where we will have all thirdparty apps or repositories. So you dont want to have any of your code inside it. infact no code in menv should be under version control/git

So we will not create any django-app inside menv. it can be at same level as menv.

to your .gitignore file please add

.vs
.vsode
myvenv/*

etc

Normally folder structure of django project is something like this ..

projectname/
   django-app1/
   django-app2/
   projectname/ # this is your main folder for settings.
      settings.py
      urls.py
      ...
    manage.py
    etc

so you would create django project you would use django-admin startproject projectname. And to create an django app from rootfloder you can use python manage.py startapp django-app1

further if you want you can create django app inside a folder called apps/ for that you need to create the folder manually and then run python manage.py startapp django-app1 apps/django-aap1

Seshadri VS
  • 550
  • 1
  • 6
  • 24
  • So if I understand this correctly, the order should be: create "root" folder, make venv inside the folder, point VSCode to the current venv, create new django project and then add to the gitignore file? – EInherjar Nov 06 '18 at 10:04
  • Yes. there are many ways to do . Thats one acceptable way. when you create a django project root folder will be created. you can have venv inside it also. all django app's will be inside the project (root) folder. Just make sure you will not add any django app's nor any specific inside venv folder. rest is fine – Seshadri VS Nov 06 '18 at 10:15
  • if you find this answer solving the issue. Can you kindly accept it – Seshadri VS Nov 06 '18 at 10:36
0

Insert anything related to vscode inside project directory and open the project at the VScode but don't forget to add .vscode* at .gitignore

projectname?/
    myproject/        #1
        .vs/
        ....
        .vsode/
        ....
        myprojectapps?/
        manage.py
    myvenv/           #2
        myproject/
            Include/
            Lib/
            Scripts/
            myprojectapps?/
            manage.py
A.Raouf
  • 2,171
  • 1
  • 24
  • 36