{"id":15380701,"url":"https://github.com/laymonage/django-template-heroku","last_synced_at":"2025-08-04T20:19:06.861Z","repository":{"id":45308976,"uuid":"299355097","full_name":"laymonage/django-template-heroku","owner":"laymonage","description":"Simple Django project template ready for Heroku deployment for Web Design and Programming course at Fasilkom UI.","archived":false,"fork":false,"pushed_at":"2021-12-22T12:50:08.000Z","size":81,"stargazers_count":22,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T23:43:45.402Z","etag":null,"topics":["django","hacktoberfest","heroku","template"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laymonage.png","metadata":{"files":{"readme":"README.en.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-28T15:39:35.000Z","updated_at":"2024-01-25T18:08:19.000Z","dependencies_parsed_at":"2022-09-15T20:12:00.171Z","dependency_job_id":null,"html_url":"https://github.com/laymonage/django-template-heroku","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laymonage%2Fdjango-template-heroku","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laymonage%2Fdjango-template-heroku/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laymonage%2Fdjango-template-heroku/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laymonage%2Fdjango-template-heroku/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laymonage","download_url":"https://codeload.github.com/laymonage/django-template-heroku/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249130685,"owners_count":21217592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["django","hacktoberfest","heroku","template"],"created_at":"2024-10-01T14:24:20.549Z","updated_at":"2025-04-15T18:40:51.885Z","avatar_url":"https://github.com/laymonage.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-template-heroku\n\n[![Test and Deploy][actions-badge]][commits-gh]\n[![pipeline status][pipeline-badge]][commits-gl]\n[![coverage report][coverage-badge]][commits-gl]\n\nThis repository contains a template for creating a Django project ready to be\ndeployed to Heroku via GitHub Actions or GitLab CI.\n\n*Untuk melihat berkas ini dalam bahasa Indonesia,\n[klik di sini][readme-id].*\n\n## Table of contents\n\n- [Table of contents](#table-of-contents)\n- [Usage instructions](#usage-instructions)\n- [Additional steps](#additional-steps)\n- [Development tips](#development-tips)\n- [What kind of magic is this?](#what-kind-of-magic-is-this)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Usage instructions\n\n1. Create a directory for the project that you want to create (example:\n   `project_name`), then open a Command Prompt (cmd) or Terminal in that\n   directory.\n\n2. Create a Python virtual environment in it.\n\n   ```shell\n   python -m venv venv\n   ```\n\n   \u003e Note: please adjust the command with the `python` executable on your\n   \u003e computer, because sometimes (example: on Ubuntu or macOS) Python 3\n   \u003e can only be executed using `python3`, not `python`.\n\n3. Activate the virtual environment that was just created.\n\n   On Windows:\n\n   ```shell\n   venv\\Scripts\\activate\n   ```\n\n   On Linux/macOS:\n\n   ```shell\n   source venv/bin/activate\n   ```\n\n   If successful, there should be `(venv)` in your cmd/terminal prompt.\n\n4. Install Django in the virtual environment.\n\n   ```shell\n   python -m pip install Django\n   ```\n\n5. Create a new Django project with this template.\n\n   ```shell\n   django-admin startproject --template=\"https://codeload.github.com/laymonage/django-template-heroku/zip/template\" --extension=\"py,yml,md\" --name=\"Procfile\" project_name .\n   ```\n\n   \u003e Note: rename `project_name` with the desired project name. Notice that\n   \u003e there is a period (`.`) at the end of the command. If there's an error\n   \u003e when downloading the template from GitHub, please visit the link manually\n   \u003e and point the `--template` argument to the location of your `.zip` file\n   \u003e that you downloaded to your computer.\n\n6. Sign in to [Heroku Dashboard][heroku-dashboard] and create a new Heroku\n   application. The application name **does not have to be the same** as the\n   name of your Django project. Then, open up the **Settings** of the\n   application. In the **Config Vars** section, click the **Reveal Config\n   Vars** button. Add a variable named `HEROKU_APP_NAME` with the name of your\n   Heroku app **without `.herokuapp.com`** as its value. Then, add another\n   variable named `SECRET_KEY` using a value generated by the\n   [Djecrety][djecrety] site.\n\n7. Create a new project/repository on GitLab/GitHub (choose one). **Do not**\n   select the options to initialize the repository with `README.md`, license,\n   or `.gitignore`. Just leave them blank.\n\n8. If you use GitLab, go to the **Settings** menu in the left sidebar. In the\n   **Variables** section, add a variable named `HEROKU_API_KEY` with the API\n   key of your Heroku account as its value. Then, add another variable named\n   `HEROKU_APP_NAME` with your Heroku app name **without `.herokuapp.com`** as\n   its value.\n\n   If you're using GitHub, do the same through the **Settings \u003e Secrets** menu.\n\n   \u003e Note: Your Heroku account's API key can be viewed on [**Account\n   \u003e settings**][account-settings].\n\n9. **If you use GitHub**, move the `tnd.yml` file to the `.github/workflows`\n   directory with the following commands.\n\n   On Windows:\n\n   ```shell\n   mkdir \".github\\workflows\"\n   move tnd.yml \".github\\workflows\\\"\n   ```\n\n   On Linux/macOS:\n\n   ```shell\n   mkdir -p .github/workflows\n   mv tnd.yml .github/workflows/\n   ```\n\n   If you only use GitLab, you can delete the `tnd.yml` file. If you only use\n   GitHub, you can delete the `.gitlab-ci.yml` file.\n\n10. Turn your project directory into a Git repository and create an initial\n    commit.\n\n    ```shell\n    git init\n    git add .\n    git commit -m \"Initial commit\"\n    ```\n\n11. Add a new remote named `origin` that points to the repository you created\n    on GitLab/GitHub, then push to that repository.\n\n    ```shell\n    git remote add origin https://gitlab.com/yourusername/project-name.git\n    git push -u origin master\n    ```\n\n12. Please check **Pipelines** on GitLab or Actions on GitHub. If the steps are\n    followed correctly, then your Django project will be successfully deployed\n    to Heroku.\n\n    \u003e Example: https://django-template-heroku.herokuapp.com\n\n13. Congratulations! Now, you just need to focus on developing your web project\n    without having to worry about deployment problems. Before developing your\n    web project, install the required packages with the following command.\n\n    ```shell\n    python -m pip install -r requirements.txt\n    ```\n\n14. Continue by creating a local database and collecting static files into a\n    single directory with the following commands.\n\n    ```shell\n    python manage.py migrate\n    python manage.py collectstatic\n    ```\n\n15. After that, you can run your web server locally with the following command.\n\n    ```shell\n    python manage.py runserver\n    ```\n\n16. From here, you just need to edit your Django project files as necessary.\n    Then, don't forget to use the `git add`, `git commit`, and `git push`\n    commands to upload your changes to GitLab/GitHub (which will then be\n    deployed to Heroku). Don't forget to make migration files if you change the\n    `models.py` file.\n\n    ```shell\n    python manage.py makemigrations\n    ```\n\n    The generated migration files should be committed into the repository\n    \u003csup\u003e\u003csub\u003e(unless you change the template configuration so that it's not\n    necessary... but why?)\u003c/sub\u003e\u003c/sup\u003e.\n\n17. To run the unit tests, you can use the following command.\n\n    ```shell\n    python manage.py test --exclude-tag=functional\n    ```\n\n## Additional steps\n\nAfter successfully creating a new Django project with this template, there are\nsome highly recommended additional steps you can do in order to ease your web\ndevelopment in the future.\n\n1. Add a new Django super user to your Heroku app.\n\n   The database used on your local computer is **different** to the one that's\n   used on Heroku. By default, you use the SQLite database stored in the\n   `db.sqlite3` file, while Heroku uses the PostgreSQL database hosted in the\n   cloud.\n\n   To be able to access your existing Django administration site on Heroku,\n   open the Heroku Dashboard. Then, click on your app and click the **More \u003e\n   Run console** option in the top right corner. Type `bash` in the pop-up\n   dialog that appears. Then, enter the command `python manage.py\n   createsuperuser` and follow the instructions.\n\n   \u003e Psst, inside `bash`, you can browse your Django projects just like from\n   \u003e the cmd/terminal! That means, you can also use other commands such as\n   \u003e `python manage.py migrate` or even Linux shell commands.\n\n2. Download `chromedriver` (or any other webdriver you want) to your computer\n   in order to run functional tests locally. **This will be very useful for one\n   of the stories.**\n\n   On Windows:\\\n   Download [ChromeDriver][chromedriver] (`chromedriver_win32.zip`) for the\n   Chrome  version that you use. Then, extract the `.zip` file and place the\n   `chromedriver.exe` in this  directory (same level as `manage.py`).\n\n   On Linux:\\\n   Some Linux distributions have their own ChromeDriver packages, or some have\n   also included it in the chromium package (e.g. Arch Linux). If there is no\n   suitable  package, you can download `chromedriver_linux64.zip` from the link\n   above, then `unzip` and put `chromedriver` into one of the existing\n   directories in your `$PATH`.\n\n   On macOS:\\\n   Install `chromedriver` with [Homebrew][homebrew] (`brew cask install\n   chromedriver`  on the Terminal). Please install Homebrew first if you\n   haven't already. I don't have a macOS device,  so please find a solution on\n   your own if there's any problem ;)\n\n   To run the functional tests only, use the following command:\n\n   ```shell\n   python manage.py test --tag=functional\n   ```\n\n   \u003e Note: if you want to use a different webdriver, please customize the\n   \u003e `tests.py` file and install the webdriver accordingly. If you want to see\n   \u003e the functional tests in action on your computer, turn off the `headless`\n   \u003e option in `tests.py`. However, don't forget to turn it back on because\n   \u003e the option is required by GitLab CI/GitHub Actions. Make sure you've run\n   \u003e the `collectstatic` command before running the functional tests.\n\n   \u003e Note for Windows users: when you run functional tests, an error such as\n   \u003e `ConnectionResetError: [WinError 10054] An existing connection was\n   \u003e forcibly closed by the remote host` may appear. As long as the tests\n   \u003e finish successfully, just ignore the error. This is a [bug][ticket-21227]\n   \u003e which has not been fixed for Django on Windows.\n\n3. Set the code coverage configuration on GitLab.\n\n   Code coverage is a useful metric for measuring how much of your code is\n   covered by  tests. GitLab has features for capturing code coverage from a\n   job log in the Pipelines. To  set it up, go to **CI/CD \u003e General\n   pipelines**. In the **Test coverage parsing** section, fill  in the\n   following regular expressions: `^TOTAL.*s+(d+%)$` (what is this for?), and\n   save it.\n\n   Later, in the **Coverage report** section there will be a coverage badge of\n   your  project. You can add this badge into the `README.md` file just like\n   this one.\n\n   To run the tests with coverage on your local computer, use the following\n   command.\n\n    ```shell\n    coverage run --include=\"./*\" --omit=\"venv/*,manage.py,project_name/*\" manage.py test\n    ```\n\n   \u003e Note: this command runs both unit tests and functional tests at once,\n   \u003e so make sure you've run the `collectstatic` command before running the tests.\n\n## Development tips\n\n1. From now on, get used to reloading your browser with\n   \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eShift\u003c/kbd\u003e+\u003ckbd\u003eR\u003c/kbd\u003e (you can also use\n   \u003ckbd\u003eShift\u003c/kbd\u003e+\u003ckbd\u003eF5\u003c/kbd\u003e on some browsers), not just\n   \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eR\u003c/kbd\u003e or \u003ckbd\u003eF5\u003c/kbd\u003e. Otherwise, when you develop\n   the web locally, you may often find that the static files that are loaded on\n   your browser do not change after you modify it. This happens because the\n   browser caches the static files for faster access. By pressing\n   \u003ckbd\u003eShift\u003c/kbd\u003e, the browser will [bypass the cached static\n   files][bypass-cache].\n2. Get used to writing quality tests for your web projects, especially for the\n   logic parts such as those in the views layer. Writing tests will make it\n   easier for you to find bugs in your program early on. Besides, tests can\n   also prevent you from creating new bugs when you develop your web project.\n3. 100% code coverage does not mean your project is bug-free. However, having\n   tests that assess your project as a whole will certainly be very useful.\n   Start writing tests every time you create a new functionality to maintain\n   your code coverage.\n4. This template intentionally does not include linting configurations such as\n   using [`flake8`][flake8] or [`pylint`][pylint]. This is done to avoid\n   warnings from appearing on your GitHub Actions or GitLab CI if your code\n   does not comply with the rules applied by the linter. If you don't want to\n   be bothered with code style, I suggest using [`black`][black] and\n   [`isort`][isort]. It's a good idea to create a configuration to run the\n   linters on GitHub Actions or GitLab CI for your project.\n\n## What kind of magic is this?\n\nThe `django-admin` tool provides the [`--template`][template] option for the\n`startproject` command that accepts a path to a template of a Django project.\nThe path can be the location of a local file/directory or the URL for an\narchive file. GitLab/GitHub provides the option to download repositories as\n`.zip` archives... you can figure out the rest :)\n\nThis template will then be rendered with variables that can be applied when\nrunning the `startproject` command. It works similarly to Django templates and\ncontext variables that can be rendered into it.\n\nPlease use this template as a **learning resource as much as possible**. It is\ntrue that this template can make it easier for you to create Django projects\nthat are ready to be deployed without having to deal with many configurations.\nHowever, it will be very beneficial for you if you understand how the\nconfigurations work in this template.\n\n## Contributing\n\nIf you would like to contribute to this template, please create an issue or\nsubmit a pull request to the repository for this template at\n[**GitHub**][repo-gh]. This repository is also mirrored to [GitLab][repo-gl]\nfor demonstration purposes.\n\n## License\n\nThis template is distributed under [The Unlicense][license] license. Projects\ngenerated with this template may be distributed under different licenses.\n\n[actions-badge]: https://github.com/laymonage/django-template-heroku/workflows/Test%20and%20Deploy/badge.svg\n[commits-gh]: https://github.com/laymonage/django-template-heroku/commits/master\n[pipeline-badge]: https://gitlab.com/laymonage/django-template-heroku/badges/master/pipeline.svg\n[coverage-badge]: https://gitlab.com/laymonage/django-template-heroku/badges/master/coverage.svg\n[commits-gl]: https://gitlab.com/laymonage/django-template-heroku/-/commits/master\n[readme-id]: README.md\n[heroku-dashboard]: https://dashboard.heroku.com\n[djecrety]: https://djecrety.ir\n[account-settings]: https://dashboard.heroku.com/account\n[chromedriver]: https://chromedriver.chromium.org/downloads\n[homebrew]: https://brew.sh\n[ticket-21227]: https://code.djangoproject.com/ticket/21227\n[bypass-cache]: https://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache\n[flake8]: https://pypi.org/project/flake8\n[pylint]: https://pypi.org/project/pylint\n[black]: https://pypi.org/project/black\n[isort]: https://pypi.org/project/isort\n[template]: https://docs.djangoproject.com/en/3.1/ref/django-admin/#cmdoption-startproject-template\n[repo-gh]: https://github.com/laymonage/django-template-heroku\n[repo-gl]: https://gitlab.com/laymonage/django-template-heroku\n[license]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaymonage%2Fdjango-template-heroku","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaymonage%2Fdjango-template-heroku","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaymonage%2Fdjango-template-heroku/lists"}