Skip to content

Commit

Permalink
Initial commit of bare bones Django setup in Docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
FrenjaminBanklin committed Feb 15, 2024
1 parent 693fadd commit d9727c7
Show file tree
Hide file tree
Showing 47 changed files with 642 additions and 1,263 deletions.
Empty file added app/core/views/__init__.py
Empty file.
Binary file added app/core/views/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added app/core/views/__pycache__/main.cpython-312.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions app/core/views/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.http import HttpResponse

def home(request):
return HttpResponse('this is Materia')
7 changes: 7 additions & 0 deletions app/logfile.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Not Found: /
Not Found: /home
Not Found: /
Not Found: /
Not Found: /home/
Not Found: /
Not Found: /home
22 changes: 22 additions & 0 deletions app/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'materia.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()
14 changes: 14 additions & 0 deletions app/materia.wsgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os,sys

sys.stdout = sys.stderr

sys.path.append('/usr/local/lib/python3.12')
sys.path.append('/usr/local/lib/python3.12/site-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = 'materia.settings'

root_path = os.path.abspath(os.path.split(__file__)[0])
sys.path.insert(0, root_path)

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Empty file added app/materia/__init__.py
Empty file.
Binary file added app/materia/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added app/materia/__pycache__/settings.cpython-312.pyc
Binary file not shown.
Binary file added app/materia/__pycache__/urls.cpython-312.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions app/materia/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for materia 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.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'materia.settings')

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

import os
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.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'materia-local-dev-secret-key'

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

ALLOWED_HOSTS = []


# Application definition

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

# apps
'core',
]

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 = 'materia.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 = 'materia.wsgi.application'


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

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ.get('MYSQL_DATABASE'),
'USER': os.environ.get('MYSQL_USER'),
'PASSWORD': os.environ.get('MYSQL_PASSWORD'),
'HOST': os.environ.get('MYSQL_HOST'),
'PORT': os.environ.get('MYSQL_PORT')
},
}


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

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'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.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'US/Eastern'

USE_I18N = True

USE_TZ = True


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

STATIC_URL = 'static/'

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

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': './logfile.log'
}
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'INFO',
'propagate': True
}
}
}
24 changes: 24 additions & 0 deletions app/materia/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
URL configuration for materia project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.0/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.urls import include, path

from core.views import main as core_views

urlpatterns = [
path('', core_views.home, name='placeholder home page')
]
16 changes: 16 additions & 0 deletions app/materia/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for materia 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.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'materia.settings')

application = get_wsgi_application()
7 changes: 7 additions & 0 deletions app/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
asgiref==3.7.2
Django==5.0.1
mysqlclient==2.2.4
setuptools==69.0.3
sqlparse==0.4.4
uWSGI==2.0.23
wheel==0.42.0
12 changes: 0 additions & 12 deletions docker/.env

This file was deleted.

Loading

0 comments on commit d9727c7

Please sign in to comment.