skip to Main Content

enter image description here[enter image description here][2]I work with Git Bash, Python, Django in a virtual environment under VS-Code and I have such a problem. When I use the $ python -m django startproject mysite command in the djangogirls directory, two nested mysite directories are created under the djangogirls directory, see a picture. But I would need only one under the djangogirls directory. How should I do that ?

everything I could think of

2

Answers


  1. Quoth the docs for startproject:

    django-admin startproject name [directory]

    Creates a Django project directory structure for the given project name in the current directory or the given destination.

    If only the project name is given, both the project directory and project package will be named and the project directory will be created in the current working directory.

    If the optional destination is provided, Django will use that existing directory as the project directory, and create manage.py and the project package within it. Use ‘.’ to denote the current working directory.

    IOW,

    $ python -m django startproject mysite .
    

    (note the trailing . to denote the current working directory.)

    Login or Signup to reply.
  2. This is expected behviour. To quote the official documentation:

    • The outer mysite/ root directory is a container for your project. Its name doesn’t matter to Django; you can rename it to anything you like.
    • The inner mysite/ directory is the actual Python package for your project. Its name is the Python package name you’ll need to use to import anything inside it (e.g. mysite.urls).
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search