project_template.rst 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. The project template
  2. ====================
  3. .. code-block:: text
  4. mysite/
  5. home/
  6. migrations/
  7. __init__.py
  8. 0001_initial.py
  9. 0002_create_homepage.py
  10. templates/
  11. home/
  12. home_page.html
  13. __init__.py
  14. models.py
  15. search/
  16. templates/
  17. search/
  18. search.html
  19. __init__.py
  20. views.py
  21. mysite/
  22. settings/
  23. __init__.py
  24. base.py
  25. dev.py
  26. production.py
  27. static/
  28. css/
  29. mysite.css
  30. js/
  31. mysite.js
  32. templates/
  33. 404.html
  34. 500.html
  35. base.html
  36. __init__.py
  37. urls.py
  38. wsgi.py
  39. Dockerfile
  40. manage.py
  41. requirements.txt
  42. The "home" app
  43. ----------------
  44. Location: ``/mysite/home/``
  45. This app is here to help get you started quicker by providing a ``HomePage`` model with migrations to create one when you first set up your app.
  46. Default templates and static files
  47. ----------------------------------
  48. Location: ``/mysite/mysite/templates/`` and ``/mysite/mysite/static/``
  49. The templates directory contains ``base.html``, ``404.html`` and ``500.html``. These files are very commonly needed on Wagtail sites to they have been added into the template.
  50. The static directory contains an empty JavaScript and CSS file.
  51. Django settings
  52. ---------------
  53. Location: ``/mysite/mysite/settings/``
  54. The Django settings files are split up into ``base.py``, ``dev.py``, ``production.py`` and ``local.py``.
  55. .. glossary::
  56. ``base.py``
  57. This file is for global settings that will be used in both development and production. Aim to keep most of your configuration in this file.
  58. ``dev.py``
  59. This file is for settings that will only be used by developers. For example: ``DEBUG = True``
  60. ``production.py``
  61. This file is for settings that will only run on a production server. For example: ``DEBUG = False``
  62. ``local.py``
  63. This file is used for settings local to a particular machine. This file should never be tracked by a version control system.
  64. .. tip::
  65. On production servers, we recommend that you only store secrets in ``local.py`` (such as API keys and passwords). This can save you headaches in the future if you are ever trying to debug why a server is behaving badly. If you are using multiple servers which need different settings then we recommend that you create a different ``production.py`` file for each one.
  66. Dockerfile
  67. ----------
  68. Location: ``/mysite/Dockerfile``
  69. Contains configuration for building and deploying the site as a `Docker <https://docs.docker.com/>`_ container. To build and use the Docker image for your project, run:
  70. .. code-block:: console
  71. docker build -t mysite .
  72. docker run -p 8000:8000 mysite