Skip to content

Commit

Permalink
Merge pull request #17 from barneydobson/initial-django-setup
Browse files Browse the repository at this point in the history
Initial django setup
  • Loading branch information
AdrianDAlessandro authored Oct 23, 2024
2 parents 3387961 + 7d3479c commit 5bd2951
Show file tree
Hide file tree
Showing 20 changed files with 253 additions and 13 deletions.
1 change: 1 addition & 0 deletions .codespell_ignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ect
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repos:
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2', --offset, '2']
exclude: manage.py
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.3
hooks:
Expand Down
15 changes: 14 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
#
# pip-compile --extra=dev --output-file=dev-requirements.txt pyproject.toml
#
asgiref==3.8.1
# via django
build==1.2.2.post1
# via pip-tools
cfgv==3.4.0
# via pre-commit
click==8.1.7
# via pip-tools
colorama==0.4.6
# via
# build
# click
# pytest
coverage[toml]==7.6.4
# via pytest-cov
distlib==0.3.9
# via virtualenv
django==5.1.2
# via rse_competencies_toolkit (pyproject.toml)
filelock==3.16.1
# via virtualenv
identify==2.6.1
Expand Down Expand Up @@ -44,9 +53,9 @@ pyproject-hooks==1.2.0
# pip-tools
pytest==8.3.3
# via
# rse_competencies_toolkit (pyproject.toml)
# pytest-cov
# pytest-mock
# rse_competencies_toolkit (pyproject.toml)
pytest-cov==5.0.0
# via rse_competencies_toolkit (pyproject.toml)
pytest-mock==3.14.0
Expand All @@ -55,8 +64,12 @@ pyyaml==6.0.2
# via pre-commit
ruff==0.7.0
# via rse_competencies_toolkit (pyproject.toml)
sqlparse==0.5.1
# via django
typing-extensions==4.12.2
# via mypy
tzdata==2024.2
# via django
virtualenv==20.27.0
# via pre-commit
wheel==0.44.0
Expand Down
14 changes: 13 additions & 1 deletion doc-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# pip-compile --extra=doc --output-file=doc-requirements.txt pyproject.toml
#
asgiref==3.8.1
# via django
babel==2.16.0
# via mkdocs-material
certifi==2024.8.30
Expand All @@ -16,8 +18,12 @@ click==8.1.7
# mkdocstrings
colorama==0.4.6
# via
# click
# griffe
# mkdocs
# mkdocs-material
django==5.1.2
# via rse_competencies_toolkit (pyproject.toml)
ghp-import==2.1.0
# via mkdocs
griffe==1.5.1
Expand Down Expand Up @@ -56,7 +62,9 @@ mkdocs==1.6.1
# mkdocstrings
# rse_competencies_toolkit (pyproject.toml)
mkdocs-autorefs==1.2.0
# via mkdocstrings
# via
# mkdocstrings
# mkdocstrings-python
mkdocs-gen-files==0.5.0
# via rse_competencies_toolkit (pyproject.toml)
mkdocs-get-deps==0.2.0
Expand Down Expand Up @@ -107,6 +115,10 @@ requests==2.32.3
# via mkdocs-material
six==1.16.0
# via python-dateutil
sqlparse==0.5.1
# via django
tzdata==2024.2
# via django
urllib3==2.2.3
# via requests
watchdog==5.0.3
Expand Down
1 change: 1 addition & 0 deletions main/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Init in main."""
1 change: 1 addition & 0 deletions main/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Register your models here."""
10 changes: 10 additions & 0 deletions main/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Main app configuration."""

from django.apps import AppConfig


class MainConfig(AppConfig):
"""Main app configuration."""

default_auto_field = "django.db.models.BigAutoField"
name = "main"
1 change: 1 addition & 0 deletions main/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Init in main/migrations."""
1 change: 1 addition & 0 deletions main/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Create your models here."""
1 change: 1 addition & 0 deletions main/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Create your tests here."""
1 change: 1 addition & 0 deletions main/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Create your views here."""
23 changes: 23 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys


def main() -> None:
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rse_competencies_toolkit.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
{ name = "Adrian D'Alessandro", email = "a.dalessandro@imperial.ac.uk" },
]
requires-python = ">=3.12"
dependencies = []
dependencies = ["django"]

[project.optional-dependencies]
dev = [
Expand Down Expand Up @@ -43,7 +43,7 @@ disallow_any_generics = true
warn_unreachable = true
warn_unused_ignores = true
disallow_untyped_defs = true
exclude = [".venv/", "docs/"]
exclude = [".venv/", "docs/", "manage.py"]

[[tool.mypy.overrides]]
module = "tests.*"
Expand Down
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@
#
# pip-compile
#
asgiref==3.8.1
# via django
django==5.1.2
# via rse_competencies_toolkit (pyproject.toml)
sqlparse==0.5.1
# via django
tzdata==2024.2
# via django
1 change: 0 additions & 1 deletion rse_competencies_toolkit/__main__.py

This file was deleted.

15 changes: 15 additions & 0 deletions rse_competencies_toolkit/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""ASGI config for rse_competencies_toolkit project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

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

application = get_asgi_application()
122 changes: 122 additions & 0 deletions rse_competencies_toolkit/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"""Django settings for rse_competencies_toolkit project.
Generated by 'django-admin startproject' using Django 5.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-!hv_9o)--3*m5m&gpk!z@*!20pn@jgbd8s7pw8@t8&%ect$3v%"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS: list[str]


# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = "rse_competencies_toolkit.urls"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = "rse_competencies_toolkit.wsgi.application"


# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}


# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", # noqa: E501
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/

LANGUAGE_CODE = "en-us"

TIME_ZONE = "UTC"

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/

STATIC_URL = "static/"

# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
23 changes: 23 additions & 0 deletions rse_competencies_toolkit/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""URL configuration for rse_competencies_toolkit project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path

urlpatterns = [
path("admin/", admin.site.urls),
]
15 changes: 15 additions & 0 deletions rse_competencies_toolkit/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""WSGI config for rse_competencies_toolkit project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()
8 changes: 0 additions & 8 deletions tests/test_rse_competencies_toolkit.py

This file was deleted.

0 comments on commit 5bd2951

Please sign in to comment.