{"id":16393668,"url":"https://github.com/code-yeongyu/drf-psql-template","last_synced_at":"2025-07-11T01:35:02.769Z","repository":{"id":112056568,"uuid":"407805849","full_name":"code-yeongyu/drf-psql-template","owner":"code-yeongyu","description":null,"archived":false,"fork":false,"pushed_at":"2021-11-28T15:36:21.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-04T04:14:21.773Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-yeongyu.png","metadata":{"files":{"readme":"README.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-18T08:43:50.000Z","updated_at":"2023-03-17T12:44:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"6da01e60-e4a0-4718-9988-dd8038d867cf","html_url":"https://github.com/code-yeongyu/drf-psql-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fdrf-psql-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fdrf-psql-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fdrf-psql-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fdrf-psql-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-yeongyu","download_url":"https://codeload.github.com/code-yeongyu/drf-psql-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240258775,"owners_count":19773056,"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":[],"created_at":"2024-10-11T04:53:58.412Z","updated_at":"2025-02-23T02:21:34.338Z","avatar_url":"https://github.com/code-yeongyu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DRF-PSQL-TEMPLATE\n\n## GET THESE JUST BY USING THIS TEMPLATE\n\n- Pre-written Dockerfile\n- Pre-setted Docker-Compose\n  - PostgreSQL Database (also for test db)\n  - Nginx\n  - WAS (Django)\n- Ready-to-production\n  - Required packages are already added to dependencies\n    - Mypy\n    - Django-stubs\n    - Poetry\n    - Pytest\n    - Django\n    - DRF\n    - Document generator: DRF-Spectacular\n    - ETC ...\n  - Seperated settings file\n  - Seperated user apps into `apps/` directory\n  - Seperated `urls.py` into `backend/` directory and `api/` directory\n\n### Examples\n\n- \u003chttps://github.com/shoeguard/shoeguard-backend\u003e\n\n## Prerequisites\n\n- python3.9\n- poetry\n- docker\n- docker-compose\n\n## Install dependencies\n\n```sh\npoetry install\n```\n\n## Run PostgreSQL\n\n```sh\ndocker compose up -d db test_db\n```\n\n## Run your shell in virtual env\n\n```sh\npoetry shell\n```\n\n## Run Django WAS\n\n```sh\npython3 manage.py runserver 0.0.0.0:8000\n```\n\n## Run WAS using Docker Compose\n\n### Define Environment Variables\n\nCreate a file named `.env` and fill following fields:\n\n```env\nDJANGO_SECRET_KEY=your secret key\nDJANGO_SETTINGS_MODULE=your settings module name\n\n# following values are optional\nPROD_DB_NAME=your production database name\nPROD_DB_USER=your production database user\nPROD_DB_PASSWORD=your production database password\nPROD_DB_HOST=your production database host\n```\n\n### Run\n\n```sh\ndocker-compose up -d --build db was ws\n```\n\n### TroubleShooting\n\nThe reason is that we haven't defined our image's version.\n\nIn this case, deleting the image that we build can be the answer, like:\n\n```sh\ndocker image rm drf-psql-template_was\n```\n\nNow you can build your application, [like above chapter](###Run).\n\n## Run Tests\n\n```sh\ndocker-compose up --build test_db\npytest -vvk .\n```\n\n---\n\n## Let's write some codes!\n\n### Create app\n\nFirst of all, let's create our app by executing following commands:\n\n```sh\npython3 manage.py startapp \"appname\"\nmv \"appname\" apps\n```\n\nSince we have seperated our own apps into `apps` directory, we have to change our app's name from `appname/apps.py`.\n\nChange like following:\n\n```python3\nfrom django.apps import AppConfig\n\n\nclass AppnameConfig(AppConfig):\n    default_auto_field = 'django.db.models.BigAutoField'\n    name = 'apps.appname'\n```\n\nMake sure you have changed `appname` into your real app name.\n\nOr you can simply edit the `name` variable from your `AppnameConfig` class.\n\nNow it's time to register our app into the settings.\n\nOpen `backend/settings/base.py` and add your app's name like:\n\n```python3\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n\n    # 3rd party\n    'rest_framework',\n    'drf_spectacular',\n\n    # my apps\n    'apps.appname',\n]\n```\n\n### Write Model\n\n### Write Serializer\n\n### Write your own view\n\n### Write some tests\n\n### Register views\n\n## What you can do more\n\n- Setup CI / CD\n- Add plugins to repository like codecov\n- ETC ...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-yeongyu%2Fdrf-psql-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-yeongyu%2Fdrf-psql-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-yeongyu%2Fdrf-psql-template/lists"}