[Django]-Django project file structure

5đź‘Ť

âś…

There is no web root. Django project files can be placed anywhere for a web server to run and serve at a given URL. URL’s do not correspond to file structure.

Django should never be exposed to the public. You stop users from downloading it by not exposing it to the public. Only static media should ever be accessible from the web.

Yes, your structure is okay. That’s the recommended new standard.

1đź‘Ť

With mod_wsgi you don’t need to declare a Document Root, you just give a path to your wsgi file

a sample apache mod_wsgi configuration from the docs:

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>

Users cannot access settings.py apache does not serve it. Make sure debug=False though as it can expose your settings

Your structure is the default django structure from 1.4+

👤dm03514

1đź‘Ť

Just to add another perspective, your URLconf, contained in urls.py, defines the virtual filesystem, if you will, of your web root. It’s up your URLconf scheme to route entire classes of URLs to your views, which generate dynamic pages. So in a sense, with a handful of URL entries, views, and templates, you can make it appear as though you have a web root with populated with countless “files”, none of which are your actual Python source code.

👤acjay

Leave a comment