Актуальный сборник шаблонов для создания проектов и приложений на 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
💨 Fast, Async-ready, Openapi, type hints based framework for building APIs

Fast to learn, fast to code, fast to run Django Ninja - Fast Django REST Framework Django Ninja is a web framework for building APIs with Django and P

Vitaliy Kucheryaviy 3.8k Jan 01, 2023
Declarative model lifecycle hooks, an alternative to Signals.

Django Lifecycle Hooks This project provides a @hook decorator as well as a base model and mixin to add lifecycle hooks to your Django models. Django'

Robert Singer 1k Dec 31, 2022
Django CacheMiddleware has a multi-threading issue with pylibmc

django-pylibmc-bug Django CacheMiddleware has a multi-threading issue with pylibmc. CacheMiddleware shares a thread-unsafe cache object with many thre

Iuri de Silvio 1 Oct 19, 2022
Django-MySQL extends Django's built-in MySQL and MariaDB support their specific features not available on other databases.

Django-MySQL The dolphin-pony - proof that cute + cute = double cute. Django-MySQL extends Django's built-in MySQL and MariaDB support their specific

Adam Johnson 504 Jan 04, 2023
Exploit Discord's cache system to remote upload payloads on Discord users machines

Exploit Discord's cache system to hide payloads PoC Remote upload embedded payload from image using EOF to Discord users machines through cache. Depen

cs 169 Dec 20, 2022
django-quill-editor makes Quill.js easy to use on Django Forms and admin sites

django-quill-editor django-quill-editor makes Quill.js easy to use on Django Forms and admin sites No configuration required for static files! The ent

lhy 139 Dec 05, 2022
A starter template for building a backend with Django and django-rest-framework using docker with PostgreSQL as the primary DB.

Django-Rest-Template! This is a basic starter template for a backend project with Django as the server and PostgreSQL as the database. About the templ

Akshat Sharma 11 Dec 06, 2022
A generic system for filtering Django QuerySets based on user selections

Django Filter Django-filter is a reusable Django application allowing users to declaratively add dynamic QuerySet filtering from URL parameters. Full

Carlton Gibson 3.9k Jan 03, 2023
A Django application that provides country choices for use with forms, flag icons static files, and a country field for models.

Django Countries A Django application that provides country choices for use with forms, flag icons static files, and a country field for models. Insta

Chris Beaven 1.2k Jan 07, 2023
A multiprocessing distributed task queue for Django

A multiprocessing distributed task queue for Django Features Multiprocessing worker pool Asynchronous tasks Scheduled, cron and repeated tasks Signed

Ilan Steemers 1.7k Jan 03, 2023
Django React Project Setup

Django-React-Project-Setup INSTALLATION: python -m pip install drps USAGE: in your cmd: python -m drps Starting fullstack project with Django and Reac

Ghazi Zabalawi 7 Feb 06, 2022
Simple web site for sharing your short stories and beautiful pictures

Story Contest Simple web site for sharing your short stories and beautiful pictures.(Cloud computing first assignment) Clouds The table below shows cl

Alireza Akhoundi 5 Jan 04, 2023
Tools to easily create permissioned CRUD endpoints in graphene-django.

graphene-django-plus Tools to easily create permissioned CRUD endpoints in graphene-django. Install pip install graphene-django-plus To make use of ev

Zerosoft 74 Aug 09, 2022
Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project

Django URL Shortener Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project Install this package to your Dja

Rishav Sinha 4 Nov 18, 2021
Simple application TodoList django with ReactJS

Django & React Django We basically follow the Django REST framework quickstart guide here. Create backend folder with a virtual Python environment: mk

Flavien HUGS 2 Aug 07, 2022
The Django Leaflet Admin List package provides an admin list view featured by the map and bounding box filter for the geo-based data of the GeoDjango.

The Django Leaflet Admin List package provides an admin list view featured by the map and bounding box filter for the geo-based data of the GeoDjango. It requires a django-leaflet package.

Vsevolod Novikov 33 Nov 11, 2022
ProjectManagementWebsite - Project management website for CMSC495 built using the Django stack

ProjectManagementWebsite A minimal project management website for CMSC495 built

Justin 1 May 23, 2022
Django app for building dashboards using raw SQL queries

django-sql-dashboard Django app for building dashboards using raw SQL queries Brings a useful subset of Datasette to Django. Currently only works with

Simon Willison 383 Jan 06, 2023
User Authentication In Django/Ajax/Jquery

User Authentication In Django/Ajax/Jquery Demo: Authentication System Using Django/Ajax/Jquery Demo: Authentication System Using Django Overview The D

Suman Raj Khanal 10 Mar 26, 2022
Coltrane - A simple content site framework that harnesses the power of Django without the hassle.

coltrane A simple content site framework that harnesses the power of Django without the hassle. Features Can be a standalone static site or added to I

Adam Hill 58 Jan 02, 2023