How to create Cookiecutter Django project with postgres and SQLite database


How to create  Cookiecutter Django project with postgres and SQLite database



Documentation: https://cookiecutter-django.readthedocs.io/en/latest/



$  pip install "cookiecutter>=1.7.0"



$ cookiecutter https://github.com/pydanny/cookiecutter-django
Cloning into 'cookiecutter-django'...
remote: Counting objects: 550, done.
remote: Compressing objects: 100% (310/310), done.
remote: Total 550 (delta 283), reused 479 (delta 222)
Receiving objects: 100% (550/550), 127.66 KiB | 58 KiB/s, done.
Resolving deltas: 100% (283/283), done.
project_name [Project Name]:example project
project_slug [reddit_clone]:example_project
author_name [Pigirl]: Pigirl
email [you@example.com]: pi@gmail.com
description [Behold My Awesome Project!]:Example project.
domain_name [example.com]: example_project.com
version [0.1.0]: 0.0.1
timezone [UTC]: America/Los_Angeles
use_whitenoise [n]: n
use_celery [n]: y
use_mailhog [n]: n
use_sentry [n]: y
use_pycharm [n]: y
windows [n]: n
use_docker [n]: n
use_heroku [n]: y
use_compressor [n]: y
Select postgresql_version:
1 - 11.3
2 - 10.8
3 - 9.6
4 - 9.5
5 - 9.4
Choose from 1, 2, 3, 4, 5 [1]: 1
Select js_task_runner:
1 - None
2 - Gulp
Choose from 1, 2 [1]: 1
Select cloud_provider:
1 - AWS
2 - GCP
3 - None
Choose from 1, 2, 3 [1]: 1
custom_bootstrap_compilation [n]: n
Select open_source_license:
1 - MIT
2 - BSD
3 - GPLv3
4 - Apache Software License 2.0
5 - Not open source
Choose from 1, 2, 3, 4, 5 [1]: 1
keep_local_envs_in_vcs [y]: y
debug[n]: n
Enter the project and take a look around:


 cd example_project/ 
$ ls


Create a git repo and push it there:

 git init
$ git add .
$ git commit -m "first awesome commit"
$ git remote add origin git@github.com:pydanny/redditclone.git
$ git push -u origin master






Quickest way create Cookiecutter Django project  SQLite database


Start a new project

Just follow the instructions described in the usage docs. It boils down to running the following command:
$ cookiecutter https://github.com/pydanny/cookiecutter-django
Enter sensible answers to the questions asked, and you’ll be good to go. If you’re not sure whether you need a certain part, you probably can skip it. The defaults are great!
If you want to add something later, that’s fine. It might be a bit more work than selecting it right away, but not impossible.

Setup the project

Alright, the project folder is created and it’s filled with useful files. What now?
Now you need to create a new virtual environment for the project so you have a nice, clean place to work. I like to use virtualenvwrapper, but that’s a tool you don’t really need. Just very convenient in the long run.
Once you have your virtualenv set up, install local dependencies of the project.
$ pip install -r requirements/local.txt

We’re almost there!

This is where you would start tinkering with Docker, or start installing PostgreSQL. But you don’t have to, remember?
Simply set an environment variable to use an SQLite database:
$ export DATABASE_URL="sqlite:///db.sqlite"
This will make Django write data to a db.sqlite file in the project’s root folder.
You’re all set! Now you can run the initial management commands and run the dev server
$ python manage.py migrate
$ python manage.py createsuperuser
$ python manage.py runserver



My Instagram

Made with by Pi-girl | Copyright © 2020 Pi-girl