{"id":27010783,"url":"https://github.com/pygraz/2025-04-01-to-orm-or-not-to-orm","last_synced_at":"2026-04-28T11:04:43.809Z","repository":{"id":283695849,"uuid":"952478894","full_name":"pygraz/2025-04-01-to-orm-or-not-to-orm","owner":"pygraz","description":"Django example using ORM and raw SQL effectively","archived":false,"fork":false,"pushed_at":"2025-04-01T12:31:44.000Z","size":28,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-01T13:32:51.918Z","etag":null,"topics":["django","example-code","python","sql"],"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/pygraz.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":"2025-03-21T10:47:58.000Z","updated_at":"2025-04-01T12:31:48.000Z","dependencies_parsed_at":"2025-03-21T16:56:44.910Z","dependency_job_id":"1686391e-f917-401b-ab9e-498765da68d1","html_url":"https://github.com/pygraz/2025-04-01-to-orm-or-not-to-orm","commit_stats":null,"previous_names":["pygraz/2025-04-01-to-orm-or-not-to-orm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygraz%2F2025-04-01-to-orm-or-not-to-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygraz%2F2025-04-01-to-orm-or-not-to-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygraz%2F2025-04-01-to-orm-or-not-to-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygraz%2F2025-04-01-to-orm-or-not-to-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pygraz","download_url":"https://codeload.github.com/pygraz/2025-04-01-to-orm-or-not-to-orm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247168583,"owners_count":20895138,"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","example-code","python","sql"],"created_at":"2025-04-04T11:27:24.232Z","updated_at":"2026-04-28T11:04:43.799Z","avatar_url":"https://github.com/pygraz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django: To ORM or not to ORM\n\nThis is a Python Django example application to show when how to use both Django's object relation mapping (ORM) and raw SQL for reporting in the same application.\n\n\u003e [!NOTE]  \n\u003e This repository and talk have been the basis for a more up-to-date talk at the\n\u003e PyCon Austria. You can find the related slides and source code at\n\u003e \u003chttps://github.com/roskakori/django-reporting-with-raw-sql\u003e.\n\n## Environment settings\n\nThe project requires an environment file named `.env` to know about the [PostgreSQL](https://www.postgresql.org/) database settings and the preferred default password for demo data.\n\nFor example:\n\n```dotenv\n# The default password for demo data.\nMT_DEFAULT_PASSWORD=\"deMo.123\"\n\n# PotgreSQL database connection\nMT_POSTGRES_HOST=localhost\nMT_POSTGRES_PORT=5422\nMT_POSTGRES_DATABASE=minitrack_local\nMT_POSTGRES_USERNAME=minitrack_local\nMT_POSTGRES_PASSWORD=${MT_DEFAULT_PASSWORD}\n```\n\n### PostgreSQL from docker container\n\nBy default, the application will connect to a local server running on port 5432 to a database `minitrack_local` with a user `minitrack_local` and the password `deMo.123`. The repository includes a `compose.yaml` which can be used with [Docker](https://www.docker.com/):\n\n```bash\ndocker compose up\n```\n\n### Existing PostgreSQL server\n\nIf you already have access to an existing Postgre server, specify the settings in the `.env`.\n\n## Project setup\n\nThe project requires [uv](https://docs.astral.sh/uv/).\n\nTo set up the project, run:\n\n```bash\nuv sync --group dev\n```\n\nIn order to keep code clean even after your own modifications, activate the pre-commit hooks:\n\n```bash\nuv run pre-commit install --install-hooks\n```\n\nNext, apply the database migrations:\n\n```bash\nuv run python manage.py migrate\n```\n\nAfter that, create an admin user to log in. The fastest way for that is:\n\n```bash\nuv run python manage.py make_demo_admin\n```\n\nThis adds an admin user named \"admin\" with the password specified with the environment variable `MT_DEFAULT_PASSWORD` (default: \"deMo.123\").\n\nAlternatively, you can use the standard management command `createsuperuser` and specify all the details yourself:\n\n```bash\nuv run python manage.py createsuperuser --username admin\n```\n\nThen run the server\n\n```bash\nuv run python manage.py runserver\n```\n\nNow connect to \u003chttp://localhost:8000/\u003e and use the login from the `createsuperuser` form above.\n\nYou can use the admin UI to create and edit data.\n\nTo get you started quickly, create a few random demo data by running:\n\n```bash\nuv run python manage.py make_demo\n```\n\n## License\n\nCopyright (c) 2025 Python User Group Graz. Distributed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpygraz%2F2025-04-01-to-orm-or-not-to-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpygraz%2F2025-04-01-to-orm-or-not-to-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpygraz%2F2025-04-01-to-orm-or-not-to-orm/lists"}