Актуальный сборник шаблонов для создания проектов и приложений на Django

Overview

О чем этот проект

Этот репозиторий с шаблонами для быстрого создания Django проекта.


В шаблоне проекта настроены следующий технологий:

  • Django
  • gunicorn (В качестве WSGI сервера)
  • Django Ninja (В качестве REST API)
  • Docker
  • Docker-compose
  • Nginx (Через Docker-compose)
  • PostgreSQL (Через Docker-compose)
  • .env (Все важные настройки проекта хранятся в переменных окружения)
  • Makefile (Готовые стандартные команды для работы с проектом)
  • npm
  • React (Для рендеринга шаблонов)
  • webpack.config.js (Для автоматической сборки React при изменении файлов)
  • .gitignore && .dockerignore

Установка

Наша задача скопировать(с заменой) данные шаблон в папку где хранятся стандартные шаблоны Djnago.


Вот пример замены стандартных шаблонов Django на наши, будем использовать виртуальное окружение venv, и Linux. ( Этот скрипт можно выполнить за одну команду).

# Создаем папку со всем проектом, И переходим в неё
dir="ИмяПроекта";
mkdir ${dir} && cd ${dir};
# Копируем этот репозиторий.
git clone https://github.com/denisxab/django-start-pack.git .;
# На всякий случай выходим из ВО если мы в нем находимся.
deactivate;
# Создаем виртуальное окружение, Актируем его, устанавливаем `Django`.
python -m venv venv && . ./venv/bin/activate && pip install Django;
# Создаем переменную с версий текущего ВО `Python`.
py_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))');
# Удаляем стандартные шаблон проекта и приложения `Django`.
rm -rf ./venv/lib/python${py_version}/site-packages/django/conf/project_template ./venv/lib/python${py_version}/site-packages/django/conf/app_template;
# Копируем шаблоны из репозитория в ВО.
cp -r project_template ./venv/lib/python${py_version}/site-packages/django/conf/ &&
cp -r app_template ./venv/lib/python${py_version}/site-packages/django/conf/ &&
# Удаляем ненужные файлы/папки.
rm -rf project_template app_template .git;
# Показать результат `Django` шаблона
tree ./venv/lib/pythonn${py_version}/site-packages/django/conf/project_template &&
tree ./venv/lib/pythonn${py_version}/site-packages/django/conf/app_template;

Использование

Создать проект (-e указывает расширение файлов которые нужно отрендерить как шаблон)

django-admin startproject <ИмяПроекта> -e py,env,dockerignore,gitignore,json;

Создать приложение (-e указывает расширение файлов которые нужно отрендерить как шаблон)

django-admin startapp <ИмяПриложения> -e py,env,dockerignore,gitignore,json;

Настроим и запустим проект.

cd <ИмяПроекта>;
# Первоначально настраиваем проект
make init_proj;
# Запуска `webpack`
make webpack_run;
# Запускам `Django` сервер (запустите в новом окне)
make dj_run;

И теперь можно начинать разрабатывать свой проект, не задумываться о первоначальных настройках.

Особенности созданного проекта через этот шаблон

  • Главное приложение теперь имеет название conf
  • Файл с переменными окружения называется __env.env
  • Все настройки проекта хранят в файле с переменными окружения ./__env.env. Его нужно держать в тайне, так как в нём будут храниться приватные настройки для БД и Django. Он уже занесен в .gitignore && .dockerignore
  • Для быстрого и удобного исполнения команд есть ./Makfile. Для исполнения этого файла необходимо иметь программу make . На Ubuntu можно скачать эту программу командой sudo apt install make.
  • Есть файл ./Dockerfile для создания контейнера с проектом. make docker_build - собрать образ (Для правильной сборки образа и контейнера прочитайте Makfile в нем уже реализованы все необходимые настройки).
  • Есть файл ./docker-compose.yml для создания контейнера с PostgreSQL и nginx. make docker_compose_up - запустить контейнеры (Для правильной сборки образа и контейнера прочитайте Makfile в нем уже реализованы все необходимые настройки).
  • В папке ./deploy/gunicorn хранятся настройки для запуска gunicorn, в этой же папке будут храниться логи от gunicorn.
  • В папке ./ <имяпроекта> /__cache храниться кеш Django. Название этой папки определено настройками settings.py->CACHES->"default"->"LOCATION"->"__cache"
  • В папке db будет храниться volumes(термин из Docker) для БД.
  • В качестве шаблонизатор будем использовать React который храниться в приложение frontend_react. Главный компонент React находиться по пути ИмяПроекта->frontend_react->src->App.js
  • Скомпилированный код webpack храниться по пути ИмяПроекта->frontend_react->static->frontend_react->public->main.js

Особенности созданного приложения через этот шаблон

  • Есть папки static, templates, templatetags
  • Есть предварительные шаблоны для моделей и админ панели
Owner
Denis Kustov
Human
Denis Kustov
Easily share data across your company via SQL queries. From Grove Collab.

SQL Explorer SQL Explorer aims to make the flow of data between people fast, simple, and confusion-free. It is a Django-based application that you can

Grove Collaborative 2.1k Dec 30, 2022
Django-gmailapi-json-backend - Email backend for Django which sends email via the Gmail API through a JSON credential

django-gmailapi-json-backend Email backend for Django which sends email via the

Innove 1 Sep 09, 2022
Template de desarrollo Django

Template de desarrollo Django Python Django Docker Postgres Nginx CI/CD Descripción del proyecto : Proyecto template de directrices para la estandariz

Diego Esteban 1 Feb 25, 2022
Realworld - Realworld using Django and HTMX

Realworld - Realworld using Django and HTMX

Dan Jacob 53 Jan 05, 2023
Django React Flight Rezervation

Django Intro & Installation python -m venv venv source ./venv/Scripts/activate pip install Django pip install djangorestframework pip install python-d

HILMI SARIOGLU 2 May 26, 2022
Meta package to combine turbo-django and stimulus-django

Hotwire + Django This repository aims to help you integrate Hotwire with Django 🚀 Inspiration might be taken from @hotwired/hotwire-rails. We are sti

Hotwire for Django 31 Aug 09, 2022
☄️ Google Forms autofill script

lazrr 'Destroy Them With Lazers' - Knife Party, 2011 Google Forms autofill script Installation: pip3 install -r requirements.txt Usage: python3 lazrr.

Serezha Rakhmanov 12 Jun 04, 2022
A feature flipper for Django

README Django Waffle is (yet another) feature flipper for Django. You can define the conditions for which a flag should be active, and use it in a num

950 Dec 26, 2022
Utilities for implementing a modified pre-order traversal tree in django.

django-mptt Utilities for implementing Modified Preorder Tree Traversal with your Django Models and working with trees of Model instances. Project hom

2.7k Jan 01, 2023
Repo for All the Assignments I have to submit for Internship Application !😅

Challenges Repository for All the Assignments I have to submit for Internship Application ! 😅 As You know, When ever We apply for an Internship, They

keshav Sharma 1 Sep 08, 2022
A package to handle images in django

Django Image Tools Django Image Tools is a small app that will allow you to manage your project's images without worrying much about image sizes, how

The Bonsai Studio 42 Jun 02, 2022
Django Fett is an incomplete code generator used on several projects

Django Fett Django Fett is an incomplete code generator used on several projects. This is an attempt to clean it up and make it public for consumption

Jeff Triplett 6 Dec 31, 2021
this is a simple backend for instagram with python and django

simple_instagram_backend this is a simple backend for instagram with python and django it has simple realations and api in 4 diffrent apps: 1-users: a

2 Oct 20, 2021
This is a template tag project for django to calculate in templates , enjoy it

Calculator-Template-Django this is a template tag project for django to calculate in templates , enjoy it Get Started : 1 - Download Source Code 2 - M

1 Feb 01, 2022
A Django backed for PostgreSQL using Psycopg 3

A Django backend for PostgreSQL using Psycopg 2 The backend passes the entire Django test suite, but it needs a few modifications to Django and to i

Daniele Varrazzo 42 Dec 16, 2022
Djangoblog - A blogging platform built on Django and Python.

djangoblog 👨‍💻 A blogging platform built on Django and Python

Lewis Gentle 1 Jan 10, 2022
English dictionary using Django based on freecodecamp

English Dictionary Hi there, i made this english dictionary using Django based on freecodecamp.org tutorial :) Table of Contents Preview Technologies

Aline Alencar 3 May 09, 2022
🌟 A social media made with Django and Python and Bulma. 🎉

Vitary A simple social media made with Django Installation 🛠️ Get the source code 💻 git clone https://github.com/foxy4096/Vitary.git Go the the dir

Aditya Priyadarshi 15 Aug 30, 2022
Zendesk Assignment - Django Based Ticket Viewer

Zendesk-Coding-Challenge Django Based Ticket Viewer The assignment has been made using Django. Important methods have been scripted in views.py. Excep

Akash Sampurnanand Pandey 0 Dec 23, 2021
An app that allows you to add recipes from the dashboard made using DJango, JQuery, JScript and HTMl.

An app that allows you to add recipes from the dashboard. Then visitors filter based on different categories also each ingredient has a unique page with their related recipes.

Pablo Sagredo 1 Jan 31, 2022