Skip to content

Commit

Permalink
Update structure and features
Browse files Browse the repository at this point in the history
  • Loading branch information
ddahan committed Oct 17, 2023
1 parent d07cc7c commit 71450b3
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 46 deletions.
31 changes: 19 additions & 12 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.black-formatter",
"charliermarsh.ruff",
"tamasfe.even-better-toml"
],
Expand Down Expand Up @@ -73,9 +72,9 @@
"*"
], // disable linting as it would be redundant with Ruff
"python.pythonPath": "/usr/local/bin/python",
"python.envFile": "${workspaceFolder}/.env",
"python.envFile": "${workspaceFolder}/config/.env",
"python.analysis.autoImportCompletions": true,
"python.analysis.importFormat": "absolute",
"python.analysis.importFormat": "relative",
"python.analysis.indexing": true,
"python.analysis.packageIndexDepths": [
{
Expand All @@ -88,20 +87,28 @@
"${workspaceFolder}/dj_apps"
// TODO: add "${workspaceFolder}/dj_apps/<my_app>" for any new app,
],
//*********************************************************************
// black
//*********************************************************************
"black-formatter.args": [
"--config",
"pyproject.toml"
],
"ruff.enableExperimentalFormatter": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
},
//*********************************************************************
// VSCODE icons
//*********************************************************************
"vsicons.presets.folders": false,
"vsicons.associations.folders": [
{
"icon": "src",
"extensions": [
"dj_apps"
],
"format": "svg",
"overrides": "new"
}
]
}
}
}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ __pycache__
staticfiles/
*.db
.env
*.DS_Store
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

## 0.0.2

- FIXME


## 0.0.1

- Initial release
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ A minimal Django Starter Template for quick SaaS.

- Main containers: Python/Django (service_app) and PostgreSQL (service_db)
- Environment variables are handled with `.env` file (via django-environ)
- Linting / Imports auto-sorting: Ruff
- Auto-Formatting: Black
- Linting / Imports auto-sorting/ Auto-formatting: Ruff
- Package management: Poetry
- No front-end configuration

Expand All @@ -22,6 +21,6 @@ A minimal Django Starter Template for quick SaaS.

#### Once the container has been created:
- Reload the container once (running the `reload window` VS Code command ) to ensure there is no error with extension activation due to a Dev Container bug.
- Create a `.env` file based on `.env.example` file.
- Create a `.env` file based on `.env.example` file in the `config` folder.
- Run `./manage.py migrate`
- Run `./manage.py runserver` and go to "http://localhost:8000/" to ensure everything works.
File renamed without changes.
File renamed without changes.
15 changes: 11 additions & 4 deletions settings.py → config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import dj_database_url
import environ

BASE_DIR = Path(__file__).resolve().parent
CONFIG_DIR = Path(__file__).resolve().parent
BASE_DIR = CONFIG_DIR.parent


##########################################################################################
Expand All @@ -17,7 +18,7 @@
# Take environment variables from .env file (if it exists)
# That's why it is important to NOT version .env file
# (otherwise prod environment will get local env file values!)
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))
environ.Env.read_env(os.path.join(CONFIG_DIR, ".env"))

##########################################################################################
# Security
Expand Down Expand Up @@ -45,7 +46,13 @@
"corsheaders",
]

MY_APPS = [] # Add your apps here
APP_FOLDER = "dj_apps"

# Create apps in dj_apps folder sothat they are automatically detected
MY_APPS = os.listdir(BASE_DIR / Path(APP_FOLDER))

for new_path in [APP_FOLDER] + [f"{APP_FOLDER}/{folder}" for folder in MY_APPS]:
sys.path.insert(0, os.path.join(BASE_DIR, new_path))

INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + MY_APPS

Expand All @@ -61,7 +68,7 @@
]

ROOT_URLCONF = "urls"
WSGI_APPLICATION = "wsgi.application"
WSGI_APPLICATION = "config.wsgi.application"

##########################################################################################
# DX: Adding apps to the path is required for auto import
Expand Down
2 changes: 1 addition & 1 deletion wsgi.py → config/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()
1 change: 0 additions & 1 deletion dj_apps/TODO

This file was deleted.

2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
42 changes: 21 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ psycopg = { extras = [
ruff = "*" # https://github.com/charliermarsh/ruff
ipdb = "*" # https://github.com/gotcha/ipdb

[tool.black]
target-version = ["py311"]


[tool.ruff]
line-length = 90
Expand Down

0 comments on commit 71450b3

Please sign in to comment.