{"id":19871915,"url":"https://github.com/saltstack-formulas/django-formula","last_synced_at":"2026-03-09T03:34:53.988Z","repository":{"id":1123560,"uuid":"12013099","full_name":"saltstack-formulas/django-formula","owner":"saltstack-formulas","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-07T20:01:05.000Z","size":252,"stargazers_count":42,"open_issues_count":6,"forks_count":26,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-05-20T09:04:31.628Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saltstack-formulas.png","metadata":{"files":{"readme":"docs/README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-08-10T00:13:18.000Z","updated_at":"2022-04-25T19:46:11.000Z","dependencies_parsed_at":"2025-04-09T15:09:31.049Z","dependency_job_id":"c71e5993-af3d-49e8-87a8-3326e0aa0a84","html_url":"https://github.com/saltstack-formulas/django-formula","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/saltstack-formulas/django-formula","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fdjango-formula","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fdjango-formula/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fdjango-formula/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fdjango-formula/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saltstack-formulas","download_url":"https://codeload.github.com/saltstack-formulas/django-formula/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fdjango-formula/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30281566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T16:13:58.259Z","updated_at":"2026-03-09T03:34:48.972Z","avatar_url":"https://github.com/saltstack-formulas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. _readme:\n\ndjango\n======\n\n|img_travis| |img_sr|\n\n.. |img_travis| image:: https://travis-ci.com/saltstack-formulas/django-formula.svg?branch=master\n   :alt: Travis CI Build Status\n   :scale: 100%\n   :target: https://travis-ci.com/saltstack-formulas/django-formula\n.. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n   :alt: Semantic Release\n   :scale: 100%\n   :target: https://github.com/semantic-release/semantic-release\n\nSet up and configure the Django web application framework.\n\n.. contents:: **Table of Contents**\n\nGeneral notes\n-------------\n\nSee the full `SaltStack Formulas installation and usage instructions\n\u003chttps://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html\u003e`_.\n\nIf you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section\n\u003chttps://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#writing-formulas\u003e`_.\n\nIf you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``,\nwhich contains the currently released version. This formula is versioned according to `Semantic Versioning \u003chttp://semver.org/\u003e`_.\n\nSee `Formula Versioning Section \u003chttps://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#versioning\u003e`_ for more details.\n\nIf you need (non-default) configuration, please pay attention to the ``pillar.example`` file and/or `Special notes`_ section.\n\nContributing to this repo\n-------------------------\n\n**Commit message formatting is significant!!**\n\nPlease see `How to contribute \u003chttps://github.com/saltstack-formulas/.github/blob/master/CONTRIBUTING.rst\u003e`_ for more details.\n\nSpecial notes\n-------------\n\nNone\n\nAvailable states\n----------------\n\n.. contents::\n   :local:\n\n``django``\n^^^^^^^^^^\n\nInstall Django from the system package manager. Note, the Django version\navailable varies by platform.\n\nExample usage::\n\n    include:\n      - django\n\n    mysite:\n      git:\n        - latest\n        - name: git@git.example.com/mysite\n        - target: /var/www/mysite\n        - require:\n            - pkg: django\n\n``django.pip``\n^^^^^^^^^^^^^^\n\nInstall Django via pip.\n\nExample usage::\n\n    include:\n      - django.pip\n\n    mysite:\n      git:\n        - latest\n        - name: git@git.example.com/mysite\n        - target: /var/www/mysite\n        - require:\n            - pip: django_pip\n\n\nFull-stack App Deployment\n-------------------------\n\nThis formula also provides an example of how Salt can be used to deploy a\nDjango app in a single command, using the `OverState System`_. It installs\nDjango into a virtualenv, using pip with a requirements.txt.\n\n.. _`OverState System`: http://docs.saltstack.com/en/latest/topics/tutorials/states_pt5.html#states-overstate\n\nThis example makes use of the following three files:\n\n* `pillar.example`_ - Pillar data\n* `overstate.single`_ - Single-host OverState deployment stages \n* `overstate.multi`_ - Multi-host OverState deployment stages\n\n.. _pillar.example: https://github.com/saltstack-formulas/django-formula/blob/master/pillar.example\n.. _overstate.single: https://github.com/saltstack-formulas/django-formula/blob/master/overstate.single\n.. _overstate.multi: https://github.com/saltstack-formulas/django-formula/blob/master/overstate.multi\n\nDeploying this example will require that the relevant files from above (the\nPillar data and appropriate OverState config file) are copied to the Master and\nedited as necessary. The Pillar data will need to be available to all involved\nminions.\n\nAdditionally, this example makes use of several other Salt formulae:\n\n* `apache-formula`_\n* `git-formula`_\n* `mysql-formula`_\n* `pip-formula`_\n* `virtualenv-formula`_\n\n.. _apache-formula: https://github.com/saltstack-formulas/apache-formula.git\n.. _git-formula: https://github.com/saltstack-formulas/git-formula.git\n.. _mysql-formula: https://github.com/saltstack-formulas/mysql-formula.git\n.. _pip-formula: https://github.com/saltstack-formulas/pip-formula.git\n.. _virtualenv-formula: https://github.com/saltstack-formulas/virtualenv-formula.git\n\nAn easy way to use these would be to add them as gitfs sources. It is not\nrecommended to add the master copy of the repo (the one within the\n`saltstack-formulas`_ account), as others may be pushing to this repository.\nInstead, it's safer to fork the repository on GitHub, and use the fork as a\ngitfs remote. For example:\n\n.. _saltstack-formulas: https://github.com/saltstack-formulas\n\n.. code-block:: yaml\n\n    gitfs_remotes:\n      - https://github.com/yourusername/django-formula.git\n      - https://github.com/yourusername/apache-formula.git\n      - https://github.com/yourusername/git-formula.git\n      - https://github.com/yourusername/mysql-formula.git\n      - https://github.com/yourusername/pip-formula.git\n      - https://github.com/yourusername/virtualenv-formula.git\n\n\nIt is also a good idea, though not mandatory, to create a branch and use that\nto make any needed changes. This allows you to pull from the\n`saltstack-formulas`_ version of the repo into your local fork's ``master``\nbranch, and evaluate the changes without causing conflicts with whatever\nchanges you made.\n\n.. code-block:: bash\n\n    $ git branch\n    * master\n    $ git checkout -b deployment\n    Switched to a new branch 'deployment'\n    $ git push -u origin deployment \n\nThis would need to be repeated for each gitfs remote.\n\nTo deploy the entire stack (Apache, MySQL, Django, application) to a single\nhost, run the following command:\n\n.. code-block:: bash\n\n    # salt-run state.over deployment /path/to/overstate.single\n\nTo deploy using one database server (and one or more web servers), run the\nfollowing command:\n\n.. code-block:: bash\n\n    # salt-run state.over deployment /path/to/overstate.multi\n\n.. note::\n\n   If you did not create a separate ``deployment`` branch as recommended above,\n   then replace ``deployment`` with ``base`` in the above ``salt-run``\n   commands.\n\n\nOther Tips\n----------\n\nCreate ``settings.py`` using data from Pillar\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe easiest way to create Django's ``settings.py`` file using data from Pillar\nis to simply transform a dictionary in YAML into a dictionary in Python.\n\n``/srv/salt/mysite.sls``::\n\n    include:\n      - django.pip\n\n    mysite:\n      git:\n        - latest\n        - name: git@git.example.com/mysite\n        - target: /var/www/mysite\n        - require:\n            - pip: django_pip\n\n    mysite_settings:\n      file:\n        - managed\n        - name: /var/www/mysite/settings.py\n        - contents: |\n            globals().update({{ salt['pillar.get']('mysite:settings') | python() | indent(8) }})\n        - require:\n          - git: mysite\n\n``/srv/pillar/mysite.sls``::\n\n    mysite:\n      settings:\n        ROOT_URLCONF: mysite.urls\n        SECRET_KEY: 'gith!)on!_dq0=2l(otd67%#0urmrk6_d0!zu)i9fn=!8_g5(c'\n        DATABASES:\n          default:\n            ENGINE: django.db.backends.mysql\n            NAME: mysitedb\n            USER: mysiteuser\n            PASSWORD: mysitepass\n            HOST: localhost\n            PORT: 3306\n        TEMPLATE_DIRS:\n          - /var/www/mysite/django-tutorial/templates\n        STATICFILES_DIRS:\n          - /var/www/mysite/django-tutorial/static\n        STATIC_ROOT: /var/www/mysite/django-tutorial/staticroot\n\nCreate ``settings.py`` with a template file\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nA more traditional (and flexible) method of creating the ``settings.py`` file\nis to actually create the file as a template.\n\n``/srv/salt/mysite/mysite.sls``::\n\n    include:\n      - django.pip\n\n    mysite:\n      git:\n        - latest\n        - name: git@git.example.com/mysite\n        - target: /var/www/mysite\n        - require:\n            - pip: django_pip\n\n    mysite_settings:\n      file:\n        - managed\n        - name: /var/www/mysite/settings.py\n        - source: salt://mysite/files/settings-tmpl.py\n        - template: jinja\n        - require:\n          - git: mysite\n\n``/srv/salt/mysite/files/settings-tmpl.py``::\n\n    {# Data can be defined inline, in Grains, in Pillar, etc #}\n\n    {% set db_settings = {\n        'default': {\n            'ENGINE': 'django.db.backends.mysql',\n            'HOST': 'localhost',\n            'NAME': 'polldb',\n            'PASSWORD': 'pollpass',\n            'PORT': 3306,\n            'USER': 'polluser',\n        }\n    } %}\n\n    {% set staticfiles_dirs_settings = [\n        '/var/www/poll/django-tutorial/static',\n    ] %}\n\n    {% set template_dirs_settings = [\n        '/var/www/poll/django-tutorial/templates',\n    ] %}\n\n    ROOT_URLCONF = mysite.urls\n\n    {# Have Salt automatically generate the SECRET_KEY for this minion #}\n    SECRET_KEY = '{{ salt['grains.get_or_set_hash']('mysite:SECRET_KEY', 50) }}'\n\n    DATABASES = {{ db_settings | python() }}\n\n    TEMPLATE_DIRS = {{ template_dirs_settings | python() }}\n\n    STATICFILES_DIRS = {{ staticfiles_dirs_settings | python() }}\n\n    STATIC_ROOT = /var/www/mysite/django-tutorial/staticroot\n\nRun ``syncdb`` or ``collectstatic`` automatically\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nA wait state can be used to trigger ``django-admin.py syncdb`` or\n``django-admin.py collectstatic`` automatically. The following example runs\nboth commands whenever the Git repository containing the \"mysite\" Django\nproject is updated.\n\n::\n\n    include:\n      - django.pip\n\n    mysite:\n      git:\n        - latest\n        - name: git@git.example.com/mysite\n        - target: /var/www/mysite\n        - require:\n            - pip: django_pip\n\n    mysite_syncdb:\n      module:\n        - wait\n        - name: django.syncdb\n        - settings_module: \"mysite.settings\"\n        - bin_env: /path/to/virtualenv          # optional\n        - pythonpath: /path/to/mysite_project   # optional\n        - watch:\n          - git: mysite\n\n    mysite_collectstatic:\n      module:\n        - wait\n        - name: django.collectstatic\n        - settings_module: \"mysite.settings\"\n        - bin_env: /path/to/virtualenv          # optional\n        - pythonpath: /path/to/mysite_project   # optional\n        - watch:\n          - git: mysite\n\nTesting\n-------\n\nLinux testing is done with ``kitchen-salt``.\n\nRequirements\n^^^^^^^^^^^^\n\n* Ruby\n* Docker\n\n.. code-block:: bash\n\n   $ gem install bundler\n   $ bundle install\n   $ bin/kitchen test [platform]\n\nWhere ``[platform]`` is the platform name defined in ``kitchen.yml``,\ne.g. ``debian-9-2019-2-py3``.\n\n``bin/kitchen converge``\n^^^^^^^^^^^^^^^^^^^^^^^^\n\nCreates the docker instance and runs the ``django.pip`` main state, ready for testing.\n\n``bin/kitchen verify``\n^^^^^^^^^^^^^^^^^^^^^^\n\nRuns the ``inspec`` tests on the actual instance.\n\n``bin/kitchen destroy``\n^^^^^^^^^^^^^^^^^^^^^^^\n\nRemoves the docker instance.\n\n``bin/kitchen test``\n^^^^^^^^^^^^^^^^^^^^\n\nRuns all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.\n\n``bin/kitchen login``\n^^^^^^^^^^^^^^^^^^^^^\n\nGives you SSH access to the instance for manual testing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaltstack-formulas%2Fdjango-formula","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaltstack-formulas%2Fdjango-formula","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaltstack-formulas%2Fdjango-formula/lists"}