Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I move my project files into the parent directory after starting a project in Django?

After I run django-admin.py startproject foobar it creates a parent foobar directory and another foobar (same name) folder within that, along with the manage.py file. The question is - should I move all of the files from /foobar/foobar into /foobar, and just delete the redundant directory? What is the reason this structure is there in the first place?

like image 423
entrepaul Avatar asked Feb 19 '23 04:02

entrepaul


2 Answers

The new project layout is there to remove sys.path hackery inside manage.py script and to eliminate nasty bugs with imports that lead to executing some code, like signal handlers, many times instead of one.

like image 154
Dmitry Shevchenko Avatar answered Apr 06 '23 21:04

Dmitry Shevchenko


From the Documentation:

mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        wsgi.py
  • The outer mysite/ directory is just a container for your project. Its name doesn't matter to Django; you can rename it to anything you like.
  • manage.py: A command-line utility that lets you interact with this Django project in various ways. You can read all the details about manage.py in django-admin.py and manage.py.
  • 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. import mysite.settings).
like image 41
FallenAngel Avatar answered Apr 06 '23 22:04

FallenAngel