Um template para quem quiser usar o Docker + PGSQL + Django.

Overview

Django + PGSQL + Docker Template

Tecnologias usadas:

- Django
- Django Rest Framework
- Docker
- Postgres

Como usar o template

  1. Se você for usar algum tipo de biblioteca adicional no projeto django, lembre-se de adicionar ao arquivo requirements.txt antes de proseguir.

  2. Mude o arquivo .env.example para .env e preencha com os dados solicitados.

# DJANGO

# DEBUG = 1 or 0
DEBUG=
SECRET_KEY=

# DJANGO_ALLOWED_HOSTS = localhost 127.0.0.1 [::1] ...
DJANGO_ALLOWED_HOSTS=

# POSTGRES
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=

# PGADMIN
PGADMIN_DEFAULT_EMAIL=
PGADMIN_DEFAULT_PASSWORD=
  1. Se quiser usar o template drf quando for iniciar a aplicação Django sinta-se a vontade. Lembre-se de checar todas as configrações tanto em settings.py quanto em outros arquivos.

  2. Com tudo preparado rode no terminal o comando:

$ docker-compose run web django-admin startproject nome_do_app .

Ele ira iniciar a build do Docker e ira criar o app django principal.

DevContainer VSCODE

Se você usa o VsCode com a extensão devcontainers você pode abrir o projeto e começar a desenvolver. Basta apenas que você inicie e selecione a Workspace web.

Usando o Docker

Caso você não use o VsCode você terá que usar o docker para fazer a migração, iniciar o server e etc.

Com isso basta apenas que você sempre o rode o comando do docker mais a operação desejada.

Exemplo:

$ docker-compose run web python manage.py migrate

ou

$ docker-compose run web python manage.py runserver

Usando o PGADMIN

Se por acaso você for usar o PGADMIN para fazer a manipulação de dados do postgres. Aqui vai umas instruções.

  1. Crie o usuário root com o comando:
$ docker-compose exec web python manage.py createsuperuser
  1. Abra o PGADMIN em localhost:5050 em algum navegador.

  2. Faça login com as informações passadas no arquivo .env

PGADMIN_DEFAULT_EMAIL=
PGADMIN_DEFAULT_PASSWORD=
  1. Crie uma conexão com o postgres usando o host db

Criando a conexão com o db.

  1. O nome que terá que ser passado é docker_django_postgres_db. ( Lembre-se que esse nome pode ser alterado no arquivo compose )

Conectando no DB

  1. Insira as informações solicitadas, ambas podem ser consultadas no arquivo .env que você tem. ( Ou se preferir no settings.py)

Detalhes da conexão

  1. E pronto, agora é só conferir as informações usando a barra lateral do PGADMIN.

DB data

Consultas/Links

Documentação do Docker com Django

Criando um projeto Django com Docker

khezen/compose-postgres Github

SeanVowles/docker-django-postgres Github

Owner
Drack
Apenas outro humano usando o GitHub
Drack
A cookiecutter template for python scripts

cookiecutter-py-script A cookiecutter template for python scripts Prerequisites Git Usage pip install cookiecutter

Zeheng Li 1 Dec 14, 2022
Mad-cookiecutter - Cookiecutter templates for MaD projects

MaD Cookiecutter Templates A set of templates that can be used to quickly get st

Machine Learning and Data Analytics Lab FAU 1 Jan 10, 2022
A full stack boilerplate for FastAPI

A full stack boilerplate for FastAPI

Tyler M. Kontra 94 Dec 13, 2022
Ultimate Django3.2 Template for starting any project from not zero!

Ultimate Django3.2 Template for starting any project from not zero!

TheAliBigdeli 37 Dec 20, 2022
Boilerplate for starting a python project

Python Project Boilerplate Simple boilerplate for starting a python proect. Using the repo Follow following steps to install client on server Create a

Prajwal Dahal 1 Nov 19, 2021
A test Django application with production-level docker setup

DockerApp A test Django application with production-level docker setup. Blog: https://medium.com/@siddharth.sahu/the-near-perfect-dockerfile-for-djang

Siddharth Sahu 44 Nov 18, 2022
NHS Theme for Streamlit applications

NHS Streamlit App Template Deployment (local) The tool has been built using Stre

nhs.pycom 3 Nov 07, 2022
Forkable, Minimal Template for Starknet Projects.

Forkable, Minimal Template for Starknet Projects.

andreas 44 Oct 09, 2022
Template repository to build PyTorch projects from source on any version of PyTorch/CUDA/cuDNN.

Template repository to build PyTorch projects from source on any version of PyTorch/CUDA/cuDNN.

Joonhyung Lee/이준형 651 Dec 12, 2022
Code Kata Python Template

Code Kata Python Template This is the code kata template for python created by Aula de Software Libre de la Universidad de Córdoba Step 1. Use this re

Sergio Gómez 2 Nov 30, 2021
Vue + Django with no compromises. Django Templates and Vue SFCs in harmony without sacrificing the full power of either.

Cookiecutter Vue Django Vue + Django with no compromise. Cookiecutter Vue Django is a framework for jumpstarting production-ready Django + Vue project

Mike Hoolehan 122 Dec 22, 2022
Setup a flask project using a single command, right from creating virtual environment to creating Procfile for deployment.

AutoFlask-Setup About AutoFlask-Setup can help you set up a new Flask Project, right from creating virtual environment to creating Procfile for deploy

Ashutosh Krishna 1 Oct 21, 2021
Backend Boilerplate using Django,celery,Redis

Backend Boilerplate using Django,celery,Redis

Daniel Mawioo 2 Sep 14, 2022
A template repository implementing HTML5 Boilerplate 8.0 in Sanic using the Domonic framework.

sanic-domonic-h5bp A template repository implementing HTML5 Boilerplate 8.0 in Sanic using the Domonic framework. If you need frontend interactivity,

PyXY 3 Dec 12, 2022
Cookiecutter Flask OpenAPI is a template for jumpstarting production-ready Flask projects quickly.

Cookiecutter Flask OpenAPI is a template for jumpstarting production-ready Flask projects quickly. It has a well organized and scalable structure. It uses API design first

Roger Camargo 3 Nov 17, 2022
A template repo for use in the Advent of Code

AoC-Template A template repo for use in the Advent of Code The README_template.md must contain "STATS_TABLE" to be replaced by the generated table, an

0 Jan 14, 2022
Open-source full-stack seed project that uses a React UI powered by a simple Flask API Server

React Flask Authentication Open-source full-stack seed project that uses a React UI powered by a simple Flask API Server.

App Generator 37 Dec 24, 2022
This is the starter for the Flask React project.

Flask React Project This is the starter for the Flask React project. Getting started Clone this repository (only this branch) git clone https://github

Jami Travers 5 May 25, 2022
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

Daniel Roy Greenfeld 10k Jan 01, 2023
Python-boilerplate - Python Boilerplate Project Structure

python-boilerplate Python Boilerplate Project Structure Folder Structure .github

1 Jan 18, 2022