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 full stack boilerplate for FastAPI

A full stack boilerplate for FastAPI

Tyler M. Kontra 94 Dec 13, 2022
This is a boilerplate for a basic backend app using Python, Django and SQLite, as developed after tutorials with Programming with Mosh

This is a boilerplate for a basic backend app using Python, Django and SQLite, as developed after tutorials with Programming with Mosh

Gustavo Catala Sverdrup 1 Jan 07, 2022
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

Parker Bolick 2 May 14, 2022
Launchr is an open source SaaS starter kit, based on Django.

Launchr Launchr is an open source SaaS starter kit. About Launchr is a fully-equipped starter template, ready to start a SaaS web app. It implements t

Jannis Gebauer 183 Jan 06, 2023
PyPC is a very simple tool that creates Python projects from templates.

PyPC (Python Project Creator) PyPC is a very simple tool that creates Python projects from templates. In 0.1v#alpha, custom template creation will be

art3m1s 1 Nov 26, 2021
Combine the power of FastAPI and Django to build a production-ready application capable of utilizing all of the best features of both worlds.

FastAPI and Django Combo This projects aims to combine FastAPI and Django to build a Production ready application capable of utilizing all of the feat

Nsikak Imoh 33 Dec 27, 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
A low dependency and really simple to start project template for Python Projects.

Python Project Template A low dependency and really simple to start project template for Python Projects. HOW TO USE THIS TEMPLATE DO NOT FORK this is

Yurii Dubinka 5 Jan 21, 2022
Python-boilerplate - Python Boilerplate Project Structure

python-boilerplate Python Boilerplate Project Structure Folder Structure .github

1 Jan 18, 2022
Template to quickly start your playwright-python project

Playwright-python template 🍪 Template to quickly start your playwright-python project Getting started • Demo • Configuration Getting started Clone th

Constantin 1 Dec 13, 2021
The Django Base Site is a Django site that is built using the best Django practices and comes with all the common Django packages that you need to jumpstart your next project.

Django Base Site The Django Base Site is a Django site that is built using the best Django practices and comes with all the common Django packages tha

Brent O'Connor 167 Jan 03, 2023
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
A boilerplate for Django web applications

Django Hackathon Starter A boilerplate application for Django web applications. If you've attented hackathons, you already know how much time can be w

David Leonard 1.6k Dec 31, 2022
A framework for launching new Django Rest Framework projects quickly.

DRFx A framework for launching new Django Rest Framework projects quickly. Comes with a custom user model, login/logout/signup, social authentication

William Vincent 400 Dec 29, 2022
Boilerplate code for a Python Flask API

MrMat :: Python :: API :: Flask Boilerplate code for a Python Flask API This variant of a Python Flask API is code-first and using native Flask Featur

0 Dec 26, 2021
Template for creating ds simple projects

ds-project-template Template for creating ds simple projects Requirements pyenv python==3.9.4 Setup For this purpose you use following commands: pytho

1 Dec 17, 2021
Django project/application starter for lazybones :)

Django Project Starter Template My custom project starter for Django! I’ll try to support every upcoming Django releases as much as I can! Requirement

Uğur Özyılmazel 40 Jul 16, 2022
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
King is a simple boilerplate from a bigger Discord Bot project created for my Discord Server.

King A simple Discord bot boilerplate. King is a simple boilerplate from a bigger Discord Bot project created for my Discord Server. I intend to showc

Xminent 0 Aug 21, 2021
Cookiecutter to create a Google Function. Powered by Poetry, GitHub actions, and Google Cloud Platform

Cookiecutter Google Function Cookiecutter template for a Google Function. Powered by Poetry, and GitHub actions. Quickstart Install the latest Cookiec

Arthur 1 Jan 07, 2022