diff options
author | 2018-08-07 15:09:08 +0100 | |
---|---|---|
committer | 2018-08-07 15:09:16 +0100 | |
commit | af54db6c136138c66cf5ca72419989525a0baa5c (patch) | |
tree | 8519aeab8d45277c51797c7dc23aacf3b56ed1bb /pydis_django | |
parent | A wizard is never late, nor is he early. (diff) |
Initial project layout for django
Diffstat (limited to 'pydis_django')
-rw-r--r-- | pydis_django/__init__.py | 0 | ||||
-rw-r--r-- | pydis_django/hosts.py | 15 | ||||
-rw-r--r-- | pydis_django/settings.py | 140 | ||||
-rw-r--r-- | pydis_django/urls/__init__.py | 0 | ||||
-rw-r--r-- | pydis_django/urls/admin.py | 6 | ||||
-rw-r--r-- | pydis_django/urls/api.py | 6 | ||||
-rw-r--r-- | pydis_django/urls/main.py | 21 | ||||
-rw-r--r-- | pydis_django/urls/staff.py | 6 | ||||
-rw-r--r-- | pydis_django/urls/wiki.py | 6 | ||||
-rw-r--r-- | pydis_django/urls/ws.py | 6 | ||||
-rw-r--r-- | pydis_django/wsgi.py | 16 |
11 files changed, 222 insertions, 0 deletions
diff --git a/pydis_django/__init__.py b/pydis_django/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/pydis_django/__init__.py diff --git a/pydis_django/hosts.py b/pydis_django/hosts.py new file mode 100644 index 00000000..898902dc --- /dev/null +++ b/pydis_django/hosts.py @@ -0,0 +1,15 @@ +from django.conf import settings +from django_hosts import host, patterns + +host_patterns = patterns( + "pydis_django.urls", + + # > | Subdomain | URL Module | Host entry name | + host(r"admin", "admin", name="admin"), + host(r"api", "api", name="api"), + host(r"staff", "staff", name="staff"), + host(r"wiki", "wiki", name="wiki"), + host(r"ws", "ws", name="ws"), + + host(r".*", "main", name=settings.DEFAULT_HOST) +) diff --git a/pydis_django/settings.py b/pydis_django/settings.py new file mode 100644 index 00000000..657fef3b --- /dev/null +++ b/pydis_django/settings.py @@ -0,0 +1,140 @@ +""" +Django settings for pydis_django project. + +Generated by 'django-admin startproject' using Django 2.1. + +For more information on this file, see +https://docs.djangoproject.com/en/2.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.1/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.getenv("SECRET_KEY", "+_x00w3e94##2-qm-v(5&-x_@*l3t9zlir1etu+7$@4%!it2##") + +ALLOWED_HOSTS = ["pythondiscord.com"] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + + "django_hosts", +] + +MIDDLEWARE = [ + "django_hosts.middleware.HostsRequestMiddleware", + + "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", + + "django_hosts.middleware.HostsResponseMiddleware", +] +ROOT_URLCONF = "pydis_django.urls.main" + +TEMPLATES = [ + { + "APP_DIRS": True, + "BACKEND": "django.template.backends.jinja2.Jinja2", + "DIRS": [os.path.join(BASE_DIR, "templates")], + + "OPTIONS": { + "builtins": [ + "django_hosts.templatetags.hosts_override", + ], + + "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 = "pydis_django.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/2.1/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": os.path.join(BASE_DIR, "db.sqlite3"), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.1/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/2.1/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.1/howto/static-files/ + +STATIC_URL = "/static/" + +# Custom settings + +DEBUG = False +DEFAULT_HOST = "main" +PARENT_HOST = "pythondiscord.com" + +if os.getenv("DEBUG") is not None: # Debug mode + ALLOWED_HOSTS = ["pythondiscord.local"] + DEBUG = True + PARENT_HOST = "pythondiscord.local:8000" + +ROOT_HOSTCONF = "pydis_django.hosts" diff --git a/pydis_django/urls/__init__.py b/pydis_django/urls/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/pydis_django/urls/__init__.py diff --git a/pydis_django/urls/admin.py b/pydis_django/urls/admin.py new file mode 100644 index 00000000..dfc73621 --- /dev/null +++ b/pydis_django/urls/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/pydis_django/urls/api.py b/pydis_django/urls/api.py new file mode 100644 index 00000000..dfc73621 --- /dev/null +++ b/pydis_django/urls/api.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/pydis_django/urls/main.py b/pydis_django/urls/main.py new file mode 100644 index 00000000..90453f65 --- /dev/null +++ b/pydis_django/urls/main.py @@ -0,0 +1,21 @@ +"""pydis_django URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.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), +] diff --git a/pydis_django/urls/staff.py b/pydis_django/urls/staff.py new file mode 100644 index 00000000..dfc73621 --- /dev/null +++ b/pydis_django/urls/staff.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/pydis_django/urls/wiki.py b/pydis_django/urls/wiki.py new file mode 100644 index 00000000..dfc73621 --- /dev/null +++ b/pydis_django/urls/wiki.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/pydis_django/urls/ws.py b/pydis_django/urls/ws.py new file mode 100644 index 00000000..dfc73621 --- /dev/null +++ b/pydis_django/urls/ws.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/pydis_django/wsgi.py b/pydis_django/wsgi.py new file mode 100644 index 00000000..17fb615f --- /dev/null +++ b/pydis_django/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for pydis_django 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/2.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pydis_django.settings') + +application = get_wsgi_application() |