Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
wip new base template
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobi-De committed Nov 16, 2023
1 parent bea9cb0 commit 62e01eb
Show file tree
Hide file tree
Showing 31 changed files with 1,027 additions and 0 deletions.
15 changes: 15 additions & 0 deletions templates/base/project_name/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DJANGO_SECRET_KEY=
DJANGO_ENV=
DJANGO_DEBUG=
DJANGO_ALLOWED_HOSTS=
DATABASE_URL=

ADMIN_URL=
DJANGO_CSRF_TRUSTED_ORIGINS=
DJANGO_AWS_ACCESS_KEY_ID=
DJANGO_AWS_SECRET_ACCESS_KEY=
DJANGO_AWS_S3_REGION_NAME=
SENTRY_DSN=

DJANGO_SUPERUSER_EMAIL=
DJANGO_SUPERUSER_PASSWORD=
132 changes: 132 additions & 0 deletions templates/base/project_name/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Pycharm
.idea/
104 changes: 104 additions & 0 deletions templates/base/project_name/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=1000']

- repo: https://github.com/myint/autoflake
rev: v2.2.1
hooks:
- id: autoflake
exclude: .*/__init__.py
alias: autoformat
args:
- --in-place
- --remove-all-unused-imports
- --expand-star-imports
- --remove-duplicate-keys
- --remove-unused-variables

- repo: https://github.com/asottile/reorder_python_imports
rev: 3.12.0
hooks:
- id: reorder-python-imports
alias: autoformat

- repo: https://github.com/rtts/djhtml
rev: 3.0.6
hooks:
- id: djhtml
entry: djhtml --tabwidth 4
alias: autoformat

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 0.1.5
hooks:
- id: ruff
args: [--fix]
alias: linting
- id: ruff-format
alias: autoformat

- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
alias: autoformat

- repo: https://github.com/adamchainz/django-upgrade
rev: 1.15.0
hooks:
- id: django-upgrade
args: [ --target-version, "4.2" ]

- repo: https://github.com/python-poetry/poetry
rev: "1.7.0"
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-export-prod
name: poetry-export-prod
args:
[
"-f",
"requirements.txt",
"-o",
"requirements.txt",
"--without-hashes"
]
- id: poetry-export-docs
name: poetry-export-docs
args:
[
"-f",
"requirements.txt",
"-o",
"docs/requirements.txt",
"--without-hashes",
"--only",
"docs",
]
# - id: poetry-export
# name: poetry-export-dev
# args:
# [
# "-f",
# "requirements.txt",
# "-o",
# "requirements-dev.txt",
# "--without-hashes",
# "--with",
# "dev",
# ]


# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: 1.7.0
# hooks:
# - id: mypy
46 changes: 46 additions & 0 deletions templates/base/project_name/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# {{ project_name }}

[![fuzzy-couscous](https://img.shields.io/badge/built%20with-fuzzy--couscous-success)](https://github.com/Tobi-De/fuzzy-couscous)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)

## Prerequisites

- `Python 3.10+`
- `Poetry 1.2+`
- `Postgresql 10+`

## Development

### Create a new virtual environment

```shell
poetry shell
```
### Install dependencies

```shell
poetry install
```

### Install pre-commit

```shell
pre-commit install
```

### Run the django development server

```
poe r
```

[poethepoet](https://github.com/nat-n/poethepoet) is the task runner used here. To see all available commands read
the `[tool.poe.tasks]`section of the `pyproject.toml` file or run `poe -h` to see the help page.

> **Note**: SITE_ID
>
> You may get an error when trying to login or signup, this is due to django-allauth, you need to create a new *site* in django
> admin and use its *ID* as the value of `SITE_ID` in the `settings.py`file.
> Create a new superuser with the `python manage.py createsuperuser` command, login to django admin then look for the `sites`
> section in the left navigation bar and create a new *site*.
Empty file.
7 changes: 7 additions & 0 deletions templates/base/project_name/config/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

application = get_asgi_application()
Loading

0 comments on commit 62e01eb

Please sign in to comment.