{"id":19874192,"url":"https://github.com/pythoninthegrass/django_hello","last_synced_at":"2025-07-13T19:07:24.874Z","repository":{"id":85073722,"uuid":"453525843","full_name":"pythoninthegrass/django_hello","owner":"pythoninthegrass","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-07T23:05:10.000Z","size":267,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T01:26:12.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pythoninthegrass.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-01-29T21:43:13.000Z","updated_at":"2022-01-29T22:24:19.000Z","dependencies_parsed_at":"2023-03-03T01:00:46.689Z","dependency_job_id":null,"html_url":"https://github.com/pythoninthegrass/django_hello","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"pythoninthegrass/python_template","purl":"pkg:github/pythoninthegrass/django_hello","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythoninthegrass%2Fdjango_hello","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythoninthegrass%2Fdjango_hello/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythoninthegrass%2Fdjango_hello/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythoninthegrass%2Fdjango_hello/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pythoninthegrass","download_url":"https://codeload.github.com/pythoninthegrass/django_hello/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythoninthegrass%2Fdjango_hello/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265191065,"owners_count":23725252,"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-11-12T16:22:16.855Z","updated_at":"2025-07-13T19:07:24.848Z","avatar_url":"https://github.com/pythoninthegrass.png","language":"Dockerfile","readme":"# django_hello\n\n![\"It's dangerous to go alone! Take this.\"](zelda.jpg)\n\n## Summary\nOftentimes the initial setup of a Python repo can take a few minutes to a couple hours.\nBy laying the foundation to rapidly implement an idea, can focus on the good bits instead of\ndevops drudgery.\n\n## Setup\n* Install \n    * [editorconfig](https://editorconfig.org/)\n    * [poetry](https://python-poetry.org/docs/)\n    * [docker-compose](https://docs.docker.com/compose/install/)\n    * [playwright](https://playwright.dev/python/docs/intro#installation)\n\n## Usage\n### Poetry\n```bash\n# Install\ncurl -sSL https://install.python-poetry.org | $(which python3) -\n\n# Change config\npoetry config virtualenvs.in-project true           # .venv in `pwd`\npoetry config experimental.new-installer false      # fixes JSONDecodeError on Python3.10\n\n# Activate virtual environment (venv)\npoetry shell\n\n# Deactivate venv\nexit  # ctrl-d\n\n# Install multiple libraries\npoetry add google-auth google-api-python-client\n\n# Initialize existing project\npoetry init\n\n# Run script and exit environment\npoetry run python your_script.py\n\n# Install from requirements.txt\npoetry add `cat requirements.txt`\n\n# Update dependencies\npoetry update\n\n# Remove library\npoetry remove google-auth\n\n# Generate requirements.txt\npoetry export -f requirements.txt --output requirements.txt --without-hashes\n```\n\n### Docker\n```bash\n# clean build (remove `--no-cache` for speed)\ndocker-compose build --no-cache --parallel\n\n# start container\ndocker-compose up --remove-orphans -d\n\n# exec into container\ndocker attach hello\n\n# run command inside container\npython hello.py\n\n# destroy container\ndocker-compose down\n```\n\n#### Docker Troubleshooting\n* Watch logs in real-time: `docker-compose logs -tf --tail=\"50\" hello`\n* Check exit code\n    ```bash\n    $ docker-compose ps\n    Name                          Command               State    Ports\n    ------------------------------------------------------------------------------\n    docker_python      python manage.py runserver ...   Exit 0\n    ```\n\n### Playwright\n```bash\n# install\npip install --upgrade pip\npip install playwright\nplaywright install\n\n# download new browsers (chromedriver, gecko)\nnpx playwright install\n\n# generate code via macro\nplaywright codegen wikipedia.org\n```\n\n### Django\n* Follow the official [Django Docker Compose article](https://docs.docker.com/samples/django/)\n    * Django dependencies\n        ```bash\n        # edit requirements.txt\n        Django\u003e=3.0,\u003c4.0\n        psycopg2\u003e=2.8\n        ```\n    * Replace the `compose.yml` and `Dockerfile`\n        ```bash\n        # compose.yml\n        version: \"3.9\"\n   \n        services:\n        db:\n            image: postgres\n            volumes:\n            - ./data/db:/var/lib/postgresql/data\n            environment:\n            - POSTGRES_NAME=postgres\n            - POSTGRES_USER=postgres\n            - POSTGRES_PASSWORD=postgres\n        web:\n            build: .\n            command: python manage.py runserver 0.0.0.0:8000\n            volumes:\n            - .:/code\n            ports:\n            - \"8000:8000\"\n            environment:\n            - POSTGRES_NAME=postgres\n            - POSTGRES_USER=postgres\n            - POSTGRES_PASSWORD=postgres\n            depends_on:\n            - db\n\n        # Dockerfile\n        # syntax=docker/dockerfile:1\n        FROM python:3\n        ENV PYTHONDONTWRITEBYTECODE=1\n        ENV PYTHONUNBUFFERED=1\n        WORKDIR /code\n        COPY requirements.txt /code/\n        RUN pip install -r requirements.txt\n        COPY . /code/\n        ```\n    * Generate the server boilerplate code\n        ```bash\n        docker-compose run web django-admin startproject composeexample .\n        ```\n    * Fix upstream import bug and whitelist all hosts/localhost\n        ```bash\n        $ vim composeexample/settings.py\n        import os\n        ...\n        ALLOWED_HOSTS = [\"*\"]\n        ```\n    * Profit\n        ```bash\n        docker-compose up\n        ```\n\n## TODO\n* ~~Add boilerplate to hello.py~~\n* ~~Poetry~~\n* ~~Dockerfile~~\n* ~~Playwright~~\n* ~~Django~~\n   * Merge with [docker_python](https://github.com/pythoninthegrass/docker_python) and put the latter on an ice float  \n* Flask\n* Terraform\n* CI/CD (e.g., [Github Actions](https://docs.github.com/en/actions), [MegaLinter](https://megalinter.github.io/latest/))\n\n## Further Reading\n[Basic writing and formatting syntax - GitHub Docs](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)\n\n[Introduction | Documentation | Poetry - Python dependency management and packaging made easy](https://python-poetry.org/docs/)\n\n[Commands | Documentation | Poetry - Python dependency management and packaging made easy](https://python-poetry.org/docs/cli#export)\n\n[Overview of Docker Compose | Docker Documentation](https://docs.docker.com/compose/)\n\n[Compose file version 3 reference | Docker Documentation](https://docs.docker.com/compose/compose-file/compose-file-v3/)\n\n[Getting started | Playwright Python | codegen macro](https://playwright.dev/python/docs/intro)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpythoninthegrass%2Fdjango_hello","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpythoninthegrass%2Fdjango_hello","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpythoninthegrass%2Fdjango_hello/lists"}