Актуальный сборник шаблонов для создания проектов и приложений на 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
Django application and library for importing and exporting data with admin integration.

django-import-export django-import-export is a Django application and library for importing and exporting data with included admin integration. Featur

2.6k Dec 26, 2022
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

Daniel Feldroy 10k Dec 31, 2022
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
Built from scratch to replicate some of the Django admin functionality and add some more, to serve as an introspective interface for Django and Mongo.

django-mongonaut Info: An introspective interface for Django and MongoDB. Version: 0.2.21 Maintainer: Jazzband (jazzband.co) This Project is Being Mov

Jazzband 238 Dec 26, 2022
Simple tagging for django

django-taggit This is a Jazzband project. By contributing you agree to abide by the Contributor Code of Conduct and follow the guidelines. django-tagg

Jazzband 3k Jan 02, 2023
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 CBV to handle multiple forms in one view

django-shapeshifter A common problem in Django is how to have a view, especially a class-based view that can display and process multiple forms at onc

Kenneth Love 167 Nov 26, 2022
The uncompromising Python code formatter

The Uncompromising Code Formatter “Any color you like.” Black is the uncompromising Python code formatter. By using it, you agree to cede control over

Python Software Foundation 30.7k Jan 03, 2023
Inject an ID into every log message from a Django request. ASGI compatible, integrates with Sentry, and works with Celery

Django GUID Now with ASGI support! Django GUID attaches a unique correlation ID/request ID to all your log outputs for every request. In other words,

snok 300 Dec 29, 2022
Realtime data read and write without page refresh using Ajax in Django.

Realtime read-write with AJAX Hey,this is the basic implementation type of ajax realtime read write from the database. where you can insert or view re

Mehedi Hasan 3 Dec 13, 2022
Django model mixins and utilities.

django-model-utils Django model mixins and utilities. django-model-utils supports Django 2.2+. This app is available on PyPI. Getting Help Documentati

Jazzband 2.4k Jan 04, 2023
E-Commerce Platform

Shuup Shuup is an Open Source E-Commerce Platform based on Django and Python. https://shuup.com/ Copyright Copyright (c) 2012-2021 by Shuup Commerce I

Shuup 2k Jan 07, 2023
A GitHub Action for checking Django migrations

🔍 Django migrations checker A GitHub Action for checking Django migrations About This repository contains a Github Action that checks Django migratio

Oda 5 Nov 15, 2022
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. An example o

pytest-dev 9.6k Jan 06, 2023
Getdp-project - A Django-built web app that generates a personalized banner of events to come

getdp-project https://get-my-dp.herokuapp.com/ A Django-built web app that gener

CODE 4 Aug 01, 2022
Django-shared-app-isolated-databases-example - Django - Shared App & Isolated Databases

Django - Shared App & Isolated Databases An app that demonstrates the implementa

Ajai Danial 5 Jun 27, 2022
django CMS Association 1.6k Jan 06, 2023
Intellicards-backend - A Django project bootstrapped with django-admin startproject mysite

Intellicards-backend - A Django project bootstrapped with django-admin startproject mysite

Fabrizio Torrico 2 Jan 13, 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
Django app for handling the server headers required for Cross-Origin Resource Sharing (CORS)

django-cors-headers A Django App that adds Cross-Origin Resource Sharing (CORS) headers to responses. This allows in-browser requests to your Django a

Adam Johnson 4.8k Jan 03, 2023