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

You might also like...
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
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

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

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

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

Generic template for python service

Cookie cutter template example Technology stack Flask Gevent UWSGI Poetry Docker Docker-compose Installation pip install cookiecutter cookiecutter git

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.

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,

A template for some new Python tool or package with a reasonable basic setup.

python-app-template A template with a reasonable basic setup, including: black (formatting) flake8 (linting) mypy (type checking) isort (import sortin

Generic python project template

generic-python-project-template generic-python-project-template STEPS - STEP 01- Create a repository by using template repository STEP 02- Clone the n

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

Owner
Drack
Apenas outro humano usando o GitHub
Drack
Django Webpack starter template for using Webpack 5 with Django 3.1 & Bootstrap 4. Yes, it can hot-reload.

Django Webpack Starter Hello fellow human. The repo uses Python 3.9.* Django 3.1.* Webpack 5.4.* Bootstrap 4.5.* Pipenv If you have any questions twe

Ganesh Khade 56 Nov 28, 2022
A project to get you started with Docker and Django.

Docker Django tl;dr $ git clone [email protected]:erroneousboat/docker-django.git $ docker-compose up Now you can access the application at https://local

JP Bruins Slot 176 Dec 29, 2022
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
Bleeding edge django template focused on code quality and security.

wemake-django-template Bleeding edge django2.2 template focused on code quality and security. Purpose This project is used to scaffold a django projec

wemake.services 1.6k Jan 4, 2023
Project template layout for Django 3.0+

Django 3.0+ project template This is a simple Django 3.0+ project template with my preferred setup. Most Django project templates make way too many as

José Padilla 649 Dec 30, 2022
Bleeding edge django template focused on code quality and security.

wemake-django-template Bleeding edge django2.2 template focused on code quality and security. Purpose This project is used to scaffold a django projec

wemake.services 1.6k Jan 8, 2023
A Django starter template with a sound foundation.

SOS Django Template SOS Django Tempalate is a Django starter template that has opinionated and good solutions while starting your new Django project.

Eray Erdin 19 Oct 30, 2022
simple flask starter app utilizing docker

Simple flask starter app utilizing docker to showcase seasonal anime using jikanpy (myanimelist unofficial api).

Kennedy Ngugi Mwaura 5 Dec 15, 2021
Brif is a boilerplate tool based on Docker and FastAPI, designed to streamline the development and deployment of IIIF compliant platforms.

brif A boilerplate tool based on Docker, designed to streamline the development and deployment of IIIF compliant platforms. Embedded with FastAPI, Cel

Pierre 8 Sep 17, 2022
Django sample app with users including social auth via Django-AllAuth

demo-allauth-bootstrap Simple, out-of-the-box Django all-auth demo app A "brochure" or visitor (no login required) area A members-only (login required

Andrew E 215 Dec 20, 2022