{"id":17062023,"url":"https://github.com/sfdye/pyconsg-workshop-cookiecutter-django","last_synced_at":"2026-05-06T17:35:23.661Z","repository":{"id":149265008,"uuid":"135421974","full_name":"sfdye/pyconsg-workshop-cookiecutter-django","owner":"sfdye","description":"Workshop material for use at PyCon APAC 2018","archived":false,"fork":false,"pushed_at":"2018-05-31T15:04:27.000Z","size":64,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-02T01:43:17.544Z","etag":null,"topics":["cookiecutter","cookiecutter-django","django","pycon","python","singapore"],"latest_commit_sha":null,"homepage":"https://pycon.sg/schedule/","language":null,"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/sfdye.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":"2018-05-30T09:44:07.000Z","updated_at":"2021-05-06T06:39:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"b21eefde-dcf8-442e-afbc-431443beb3f2","html_url":"https://github.com/sfdye/pyconsg-workshop-cookiecutter-django","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sfdye/pyconsg-workshop-cookiecutter-django","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfdye%2Fpyconsg-workshop-cookiecutter-django","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfdye%2Fpyconsg-workshop-cookiecutter-django/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfdye%2Fpyconsg-workshop-cookiecutter-django/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfdye%2Fpyconsg-workshop-cookiecutter-django/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sfdye","download_url":"https://codeload.github.com/sfdye/pyconsg-workshop-cookiecutter-django/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfdye%2Fpyconsg-workshop-cookiecutter-django/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32704638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T08:33:17.875Z","status":"ssl_error","status_checked_at":"2026-05-06T08:33:17.221Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cookiecutter","cookiecutter-django","django","pycon","python","singapore"],"created_at":"2024-10-14T10:48:58.565Z","updated_at":"2026-05-06T17:35:23.642Z","avatar_url":"https://github.com/sfdye.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyconsg-workshop-cookiecutter-django\n\nHello, gooooood morning! \n\n:cookie: Welcome to the cookiecutter-django workshop! My name is Liuyang. I am one of the maintainers of [cookiecutter-django]. Today allow me to introduce this awesome project to you. Hopefully you will find it useful.\n\n\n\u003e What is the best practice for XXX in Django?\n\n\u003e How can I enable HTTPS for Django?\n\n\u003e What is the recommendation project structure for Django?\n\n\u003e How to integrate Docker with Django?\n\nIf you ever ask yourself asking these questions, cookiecutter-django might just be the answer you are looking for.\n\n![cookiecutter](https://camo.githubusercontent.com/c2095c350e36abaafd738dcdc6cdc9e7d585d69e/68747470733a2f2f7261772e6769746875622e636f6d2f617564726579722f636f6f6b69656375747465722f336163303738333536616466356131613732303432646665373265626661346139636435656633382f6c6f676f2f636f6f6b69656375747465725f6d656469756d2e706e67)\n\n## Prerequisites\n\n* Git\n* Docker\n* Github account\n* Text editor or IDE (e.g. VSCode or PyCharm)\n\n## Workshop\n\nDocker is an extremely useful tool to speed up the development and deployment cycle. We will use Docker throughout this workshop. It is available for all the major platforms. When if doubt, please reach out to the workshop conductor.\n\n* Install Docker\nfor [Mac](https://docs.docker.com/docker-for-mac/install/) or [Windows](https://store.docker.com/editions/community/docker-ce-desktop-windows)\n\n* Install cookiecutter CLI \n\n[cookiecutter] is a great tool developed to quickly start a project based on a certain \"template\". In this workshop, we will use the [cookiecutter-django] template which is specifically designed for Django with many best practices baked in.\n\n```bash\n# for Mac\n$ brew install cookiecutter\n\n# or generally\n$ pip install cookiecutter\n```\n\n* Createa a new Django project using cookiecutter\n\nLater you will be asked a series of questions. Based on your answer, a customerized project will be generated. For the purpose of this workshop, you may use the follow answer as a guide.\n\n```bash\n# Here cookiecutter CLI is taking the first parameter as the template source\n# In this example, it's a Github repo and cookiecutter will use the latest master at this \n# point of time. The following questions may vary depending on when you run the command \n\n$ cookiecutter https://github.com/pydanny/cookiecutter-django\n\nproject_name [My Awesome Project]: my-favorite-cookie (or whatever cool name you like)\nproject_slug [my_favorite_cookie]: my_favorite_cookie (or whatever cool name you like)\ndescription [Behold My Awesome Project!]: this is my favorite cookie \nauthor_name [Daniel Roy Greenfeld]: Your name\ndomain_name [example.com]: enter\nemail [wan-liuyang@example.com]: your email\nversion [0.1.0]: enter\nSelect open_source_license:\n1 - MIT\n2 - BSD\n3 - GPLv3\n4 - Apache Software License 2.0\n5 - Not open source\nChoose from 1, 2, 3, 4, 5 [1]: 1\ntimezone [UTC]: enter\nwindows [n]: Choose accordingly\nuse_pycharm [n]: n\nuse_docker [n]: y (***Important!***)\nSelect postgresql_version:\n1 - 10.3\n2 - 10.2\n3 - 10.1\n4 - 9.6\n5 - 9.5\n6 - 9.4\n7 - 9.3\nChoose from 1, 2, 3, 4, 5, 6, 7 [1]: 4 (***Important!***)\nSelect js_task_runner:\n1 - None\n2 - Gulp\nChoose from 1, 2 [1]: 1\ncustom_bootstrap_compilation [n]: n\nuse_compressor [n]: n\nuse_celery [n]: n\nuse_mailhog [n]: y (***Important!***)\nuse_sentry [n]: n\nuse_whitenoise [n]: n\nuse_heroku [n]: y\nuse_travisci [n]: y\nkeep_local_envs_in_vcs [y]: y\ndebug [n]: n\n [SUCCESS]: Project initialized, keep up the good work!\n```\n\nThat's it. You now have a production-ready Django project.\n\n### Run the project using Docker\n\n```\n# Make sure docker and docker-compose are installed correctly\n$ docker version\n$ docker-compose version\n\n# Navigate to the project\n$ cd my_favorite_cookie # change to your project name\n\n# Build docker image using docker-compose\n$ docker-compose -f local.yml build\n```\n\nNote: if you get a `Couldn't connect to Docker daemon at http+unix://var/run/docker.sock` error, append the docker command with `sudo`, or add the current user to the `docker` group:\n\n```\n# Replace ${USER} with your username if it doesn't work\n# After this command finishes, you need to log out and log in for it to take effect\n$ sudo usermod -aG docker ${USER} \n```\n\nIf you face some errors while docker build, you may need to change to another Docker registery mirror. (e.g. https://registry.docker-cn.com). Because there might be some problems with NUS Wifi.\n\nFor Mac:\nOpen the Docker app, \"Daemon\" -\u003e \"Registry mirrors\" -\u003e Add \"https://registry.docker-cn.com\"\n \nFor Ubuntu:\nhttps://docs.docker.com/registry/recipes/mirror/#configure-the-docker-daemon\n\n\nNow, this step will probably take a while, depending how fast your network is. I strongly recommend you to get a :coffee:. Essentially Docker is building your images based on the definition in the `local.yml` file. This file is for your development envionment. Similarly, you will also find `production.yml` in the project. \n\nThis will install all the dependecies needed to run your project, like the database, your OS dependenceis, your requirements.txt and etc. If you are interested, take a look at the logs.\n\n```\n# Run the docker image we just built \n$ docker-compose -f local.yml up\n```\n\nNow we are running the images we just built, and turn them into running containers! This will start your database, apply migrations and start the developement server. This step should be pretty fast compared the last one.\n\nNow you have a running Django project. See it in action at http://0.0.0.0:8000.\n\n![image](https://user-images.githubusercontent.com/1016390/40727172-eaac09da-6459-11e8-8ce0-547a9a42647e.png)\n\nAs you can probably see, it has a nice UI (powered by Boostrap 4), django-debug-toolbar, a working user registration system ready for use. Now let's try to create an account.\n\n### Register an account\n![image](https://user-images.githubusercontent.com/1016390/40727459-841ff338-645a-11e8-925f-17453ec437fe.png)\n\nFill in the email, password and repeat password, click \"Sign up\". You will probably wonder, where did the confirmation email go? Don't worry. cookiecutter-django actually generates a local email server (mailhog in the `local.yml`) for you. Now let's navigate to http://0.0.0.0:8025. The email is just lying in the mailbox. Awesome!\n\n![image](https://user-images.githubusercontent.com/1016390/40727683-fbc65cc4-645a-11e8-8c36-ab2aa2baccbb.png)\n\n### Adding Github Social Login\n\nBy default, cookiecutter-django installs https://github.com/pennersr/django-allauth for you, so we can quickly enable Github social login feature.\n\n1. Open the project in your text editor or IDE\n2. Navigate to `base.py`\n3. Add the following line to THIRD_PARTY_APPS. So it will look like this:\n```\nTHIRD_PARTY_APPS = [\n    'crispy_forms',\n    'allauth',\n    'allauth.account',\n    'allauth.socialaccount',\n    'allauth.socialaccount.providers.github', # \u003c-- we just added this\n    'rest_framework',\n]\n```\n4. Save and refresh. Now you will see the Github button in the sign in page (http://0.0.0.0:8000/accounts/login/)\n![image](https://user-images.githubusercontent.com/1016390/40729018-0196b880-645e-11e8-8d33-3f8b8f5d25f0.png)\n\n\nIf you click the click the link now, you will probably get a `SocialApp matching query does not exist`. That is because we haven't configured a Github Oauth app for django-allauth yet. \n\n#### Create superuser\nTo do this, we need login to Django admin (or modify the database directly). \n\nFirst let's create a superuser. Note that we now need to run the `mange.py` commands inside a Docker container.\n```\n# Open a new terminal tab and cd the right location\n$ docker-compose -f local.yml run django python manage.py createsuperuser\n```\nNow we can log in to Django admin: http://0.0.0.0:8000/admin\n\n#### Create a Github Oauth app\n\n1. Go to: https://github.com/settings/developers\n2. Click \"New Oauth App\"\n3. For Homepage URL and Authorization callback URL, just put http://0.0.0.0:8000\n4. Click \"Register Application\"\n\n![image](https://user-images.githubusercontent.com/1016390/40730300-e8305038-6460-11e8-8e0e-3c8c93df1959.png)\n\n#### Adding the Client ID and Client Secret \n![image](https://user-images.githubusercontent.com/1016390/40729330-b40f5508-645e-11e8-88f6-a6c4e34945d3.png)\n\nClick \"Social applications\", and then \"Add Social Application\". Fill the Client ID and Client Secret from the Oauth app we just registered with Github. Don't forget to link the site with this social app by double clicking on the \"example.com\", or click the right arrow.\n\n![image](https://user-images.githubusercontent.com/1016390/40729614-557d723a-645f-11e8-9e9f-7754459b55c0.png)\n\nOnce this is done. Go back to the sign in page (http://0.0.0.0:8000/accounts/login/) and sign in with Github again.\n\n![image](https://user-images.githubusercontent.com/1016390/40730028-4d8d4a36-6460-11e8-9e7b-594baa90930f.png)\n\n![image](https://user-images.githubusercontent.com/1016390/40730075-6d3959f6-6460-11e8-95c3-8b6fad6a6f54.png)\n\nVoilà, it works!\n\n### The end\n\nNow you have seen the power of [cookiecutter-django] and how easy it is to create a beautiful application with it. You may ask, why not just use the built-in `django-admin startproject`? Well, the default is too simple and not very useful if you want to build something fast and production-ready. For me, `cookiecutter` is kind of like `create-react-app` or `vue-cli`, but for Django. As you can see, there are tons of other features not covered in this workshop. Give it a shot and you will love them.\n\n![image](https://user-images.githubusercontent.com/1016390/40730739-f3392b02-6461-11e8-90ad-50ec72c0cf19.png)\n\n### More questions?\n\nIf you have any question regarding `cookiecutter-django`, feel free to open an issue [here](https://github.com/pydanny/cookiecutter-django/issues/new/choose) or shout out at the [Gitter](https://gitter.im/pydanny/cookiecutter-django) channel. The friendly community will help you out.\n\n[cookiecutter]: https://github.com/audreyr/cookiecutter\n[cookiecutter-django]: https://github.com/pydanny/cookiecutter\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfdye%2Fpyconsg-workshop-cookiecutter-django","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsfdye%2Fpyconsg-workshop-cookiecutter-django","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfdye%2Fpyconsg-workshop-cookiecutter-django/lists"}