Актуальный сборник шаблонов для создания проектов и приложений на 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
based official code from django channels, replace frontend with reactjs

django_channels_chat_official_tutorial demo project for django channels tutorial code from tutorial page: https://channels.readthedocs.io/en/stable/tu

lightsong 1 Oct 22, 2021
Use webpack to generate your static bundles without django's staticfiles or opaque wrappers.

django-webpack-loader Use webpack to generate your static bundles without django's staticfiles or opaque wrappers. Django webpack loader consumes the

2.4k Dec 24, 2022
Forgot password functionality build in Python / Django Rest Framework

Password Recover Recover password functionality with e-mail sender usign Django Email Backend How to start project. Create a folder in your machine Cr

alexandre Lopes 1 Nov 03, 2021
A Redis cache backend for django

Redis Django Cache Backend A Redis cache backend for Django Docs can be found at http://django-redis-cache.readthedocs.org/en/latest/. Changelog 3.0.0

Sean Bleier 1k Dec 15, 2022
Silk is a live profiling and inspection tool for the Django framework.

Silk is a live profiling and inspection tool for the Django framework. Silk intercepts and stores HTTP requests and database queries before presenting them in a user interface for further inspection:

Jazzband 3.7k Jan 02, 2023
Drf-stripe-subscription - An out-of-box Django REST framework solution for payment and subscription management using Stripe

Drf-stripe-subscription - An out-of-box Django REST framework solution for payment and subscription management using Stripe

Oscar Y Chen 68 Jan 07, 2023
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App 💛 We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

imagine.ai 68 Oct 19, 2022
Full control of form rendering in the templates.

django-floppyforms Full control of form rendering in the templates. Authors: Gregor Müllegger and many many contributors Original creator: Bruno Renié

Jazzband 811 Dec 01, 2022
Chatbot for ordering and tracking a Pizza.

Pizza Chatbot To start the app, follow the below steps: Clone the repo using the below command: git clone Shreya Shah 1 Jul 15, 2021

Simple Login Logout System using Django, JavaScript and ajax.

Djanog-UserAuthenticationSystem Technology Use #version Python 3.9.5 Django 3.2.7 JavaScript --- Ajax Validation --- Login and Logout Functionality, A

Bhaskar Mahor 3 Mar 26, 2022
Django models and endpoints for working with large images -- tile serving

Django Large Image Models and endpoints for working with large images in Django -- specifically geared towards geospatial tile serving. DISCLAIMER: th

Resonant GeoData 42 Dec 17, 2022
This is django-import-export module that exports data into many formats

django-import-export This is django-import-export module which exports data into many formats, you can implement this in your admin panel. - Dehydrat

Shivam Rohilla 3 Jun 03, 2021
Easy thumbnails for Django

Easy Thumbnails A powerful, yet easy to implement thumbnailing application for Django 1.11+ Below is a quick summary of usage. For more comprehensive

Chris Beaven 1.3k Dec 30, 2022
Boilerplate Django Blog for production deployments!

CFE Django Blog THIS IS COMING SOON This is boilerplate code that you can use to learn how to bring Django into production. TLDR; This is definitely c

Coding For Entrepreneurs 26 Dec 09, 2022
xsendfile etc wrapper

Django Sendfile This is a wrapper around web-server specific methods for sending files to web clients. This is useful when Django needs to check permi

John Montgomery 476 Dec 01, 2022
Django Advance DumpData

Django Advance Dumpdata Django Manage Command like dumpdata but with have more feature to Output the contents of the database from given fields of a m

EhsanSafir 7 Jul 25, 2022
Django's class-based generic views are awesome, let's have more of them.

Django Extra Views - The missing class-based generic views for Django Django-extra-views is a Django package which introduces additional class-based v

Andy Ingram 1.3k Jan 04, 2023
Automatically deletes old file for FileField and ImageField. It also deletes files on models instance deletion.

Django Cleanup Features The django-cleanup app automatically deletes files for FileField, ImageField and subclasses. When a FileField's value is chang

Ilya Shalyapin 838 Dec 30, 2022
Updates redisearch instance with igdb data used for kimosabe

igdb-pdt Update RediSearch with IGDB games data in the following Format: { "game_slug": { "name": "game_name", "cover": "igdb_coverart_url",

6rotoms 0 Jul 30, 2021
Use heroicons in your Django and Jinja templates.

heroicons Use heroicons in your Django and Jinja templates. Requirements Python 3.6 to 3.9 supported. Django 2.2 to 3.2 supported. Are your tests slow

Adam Johnson 52 Dec 14, 2022