{"id":28739846,"url":"https://github.com/codingforentrepreneurs/cfe-django-blog","last_synced_at":"2025-09-01T07:32:53.630Z","repository":{"id":41863992,"uuid":"471110736","full_name":"codingforentrepreneurs/cfe-django-blog","owner":"codingforentrepreneurs","description":"Boilerplate Django Blog for production deployments! ","archived":false,"fork":false,"pushed_at":"2022-10-18T18:46:06.000Z","size":129,"stargazers_count":31,"open_issues_count":0,"forks_count":14,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-08-30T05:44:29.842Z","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/codingforentrepreneurs.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}},"created_at":"2022-03-17T19:10:59.000Z","updated_at":"2025-04-04T07:00:51.000Z","dependencies_parsed_at":"2023-01-20T02:01:10.617Z","dependency_job_id":null,"html_url":"https://github.com/codingforentrepreneurs/cfe-django-blog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codingforentrepreneurs/cfe-django-blog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingforentrepreneurs%2Fcfe-django-blog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingforentrepreneurs%2Fcfe-django-blog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingforentrepreneurs%2Fcfe-django-blog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingforentrepreneurs%2Fcfe-django-blog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codingforentrepreneurs","download_url":"https://codeload.github.com/codingforentrepreneurs/cfe-django-blog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingforentrepreneurs%2Fcfe-django-blog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273088753,"owners_count":25043556,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-06-16T06:11:01.818Z","updated_at":"2025-09-01T07:32:53.557Z","avatar_url":"https://github.com/codingforentrepreneurs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CFE Django Blog\n\nThis is boilerplate code that you can use to learn how to bring Django into production.\n\n## TLDR;\n\nThis is definitely coming soon -- basically a list of all commands to get this repo working locally.\n\n## Getting Started\n\n### Step 1: Fork / Clone\n\nFirst, decide where this project will live.\n\n```\nmkdir -p ~/dev\ncd ~/dev\n```\n\n\u003e I always use the `~/Dev` folder which translates to `/users/cfe/Dev` (macOS / Linux) or `C:\\Users\\cfe\\Dev` (windows). This location is optional.\n\nFork or clone this repo:\n\n```\ngit clone https://github.com/codingforentrepreneurs/cfe-django-blog\n```\n\n### Step 2: Create a Virtual Environment\n\nIsolate your python project from other python projects by using the built-in [venv](https://docs.python.org/dev/library/venv.html) module:\n\n```\npython3.10 -m venv venv\n```\n\n- I recommend Python 3.8 and up\n- You can use _any_ virtual environment manager (poetry, pipenv, virtualenv, etc)\n\n### Step 3: Activate Virtual Environment\n\n_macOS/Linux_\n\n```\nsource venv/bin/activate\n```\n\n_Windows_\n\n```\n.\\venv\\Scripts\\activate\n```\n\n### Step 4: Install Requirements\n\n```\n$(venv) python -m pip install pip --upgrade\n$(venv) python -m pip install -r requirements.txt\n```\n\n- `$(venv)` is merely denoting the virtual environment is activated\n- In `requirements.txt` you'll see `django\u003e=3.2,\u003c4.0` -- this means I'm using the latest version of Django 3.2 since it's an LTS release.\n- You can use `venv/bin/python -m pip install -r requirements.txt` (mac/linux) or `venv\\bin\\python -m pip install -r requirements.txt` (windows)\n- `pip install ...` is not as reliable as `python -m pip install ...`\n\n### Step 5: Select a Database\n\nAs of now, we have the following supported databases for this boilerplate code: `sqlite`, `mysql`, `postgres`\n\n#### `sqlite`\n\nNo action needed. Django will managed sqlite for you.\n\n#### `mysql`\n\nTo install Python client:\n\n```\n$(venv) python -m pip install mysqlclient\n```\n\n\u003e If macOS, you must run `brew install mysql` (assuming you have [homebrew](https://brew.sh) installed)\n\nBe sure you add `mysqlclient` to `requirements.txt` like:\n\n```\necho \"mysqlclient\" \u003e\u003e requirements.txt\n```\n\n\u003e Using the double `\u003e\u003e` vs a single `\u003e` is the difference between appending and overwriting respectively.\n\n#### `postgres`\n\n```\n$(venv) python -m pip install psycopg2\n```\n\n\u003e You may need to use `python -m pip install psycopg2-binary` during development.\n\nBe sure you add `psycopg2` to `requirements.txt` like:\n\n```\necho \"psycopg2\" \u003e\u003e requirements.txt\n```\n\n\u003e Using the double `\u003e\u003e` vs a single `\u003e` is the difference between appending and overwriting respectively.\n\n### Step 6: Setup your `.env`\n\nCreate your `.env` file (or reference the `.env-sample` in the repo).\n\n```\necho \"\" \u003e .env\n```\n\nBelow is an example of _development-ready_ `.env` file for this project. **ALWAYS** update these values when going into production.\n\n```\n# required keys\nDJANGO_SECRET_KEY=gy_1$n9zsaacs^a4a1\u0026-i%e95fe\u0026d3pa+e^@5s*tke*r1b%*cu\nDATABASE_BACKEND=postgres\n\n# mysql db setup\nMYSQL_DATABASE=cfeblog-m-db\nMYSQL_USER=cfeblog-m-user\nMYSQL_PASSWORD=RaSNF5H3ElCbDrGUGpdRSEx-IuDzkeHFL_S_QBuH5tk\nMYSQL_ROOT_PASSWORD=2mLTcmdPzU2LOa0TpAlLPoNf1XtIKsKvNn5WBiszczs\nMYSQL_TCP_PORT=3007\nMYSQL_HOST=127.0.0.1\n\n# postgres db setup\nPOSTGRES_DB=cfeblog-p-db\nPOSTGRES_USER=cfeblog-m-user\nPOSTGRES_PASSWORD=NwgFCimzL0Oqd539EYzsztY04uzw2jaVEIrH1OK2sz0\nPOSTGRES_PORT=5431\nPOSTGRES_HOST=localhost\n```\n\nTo generate secrets use one of the following method(s):\n\n##### Use Django to create a one-off secret key (bookmark this [blog post](https://www.codingforentrepreneurs.com/blog/create-a-one-off-django-secret-key/)):\n\n```\npython -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'\n```\n\nThis is the recommended method for creating the `DJANGO_SECRET_KEY`\n\n##### Use Python to create a url safe secret:\n\n```\npython -c \"import secrets;print(secrets.token_urlsafe(32))\"\n```\n\n### Step 6: Local Development with Docker Compose\n\nRunning our local environment with the same type of database as our production database is critical. For this, we'll use Docker and Docker Compose.\n\nWith Docker, your machine can have a _lot_ of instances of MySQL/Postgres/Redis running with minimal configuration. This is true for macOS, Windows, and nearly all distros of Linux that can run Docker.\n\nWithout Docker, having more than 1 version of any of these running is a huge pain. A pain that _might_ be worth going through if you like to bleed from your eyes. It's also an uncessary pain because we're talking about the _development_ environment.\n\nNow on to the nitty gritty.\n\nIn our `docker-compose.yaml` file, you'll see configuration for the services:\n\n- `mysql_db`\n- `postgres_db`\n- `redis_db`\n\nBut wait, there is not a `web` service for Django in `docker-compose.yaml`... why not? Two reasons:\n\n- If you need it, you can add it.\n- If you're new to Python, Virtual Environments, Django, Docker, VSCode, Git, or whatever it makes things even more complex.\n\nIf you're new to Docker compose, this might suck too. Sorry about that. But I hope you trust me that, in this case, the juice is worth the squeeze (aka it's worth the effort in learning how to use it).\n\nSince I wanted to support both `mysql` and `postgres` I wanted to make use of Docker Compose's [profiles](https://docs.docker.com/compose/profiles/) feature.\n\nBasicaly, you can use a profile to \"activate\" different services within a Docker compose file (instead of having a bunch of different Docker compose files).\n\nIn our case, `docker-compose.yaml` has three profiles:\n\n- `mysql` (includes the `mysql_db` and `redis_db` services)\n- `postgres` (includes the `postgres_db` and `redis_db` services)\n- `redis` (runs only the `redis_db` service)\n\nTo run any given profile you just do:\n\n```\ndocker compose --profile mysql up\n```\n\n\u003e Just replace `--profile postgres` if you want to use that one.\n\nAlso, keep in mind that some systems require you to use `docker-compose` instead of `docker compose`.\n\nI recommend running this profile in background mode (aka detached mode):\n\n```\ndocker compose --profile mysql up -d\n```\n\n\u003e Again, just replace `--profile postgres` if you want to use that one.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingforentrepreneurs%2Fcfe-django-blog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodingforentrepreneurs%2Fcfe-django-blog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingforentrepreneurs%2Fcfe-django-blog/lists"}