├── core ├── __init__.py ├── asgi.py ├── wsgi.py ├── urls.py └── settings.py ├── home ├── __init__.py ├── migrations │ └── __init__.py ├── models.py ├── admin.py ├── tests.py ├── urls.py ├── apps.py └── views.py ├── static └── .gitkeep ├── templates ├── .gitkeep └── pages │ ├── sign-up.html │ └── sign-in.html ├── .env ├── db.sqlite3 ├── .gitignore ├── requirements.txt ├── env.sample ├── gunicorn-cfg.py ├── nginx └── appseed-app.conf ├── Dockerfile ├── render.yaml ├── docker-compose.yml ├── manage.py ├── LICENSE.md ├── package.json ├── gulpfile.js ├── CHANGELOG.md └── README.md /core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /home/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /home/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | DEBUG=True 2 | 3 | SECRET_KEY= 4 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/app-generator/django-tabler/HEAD/db.sqlite3 -------------------------------------------------------------------------------- /home/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /home/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /home/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /home/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | path('', views.index, name='index'), 7 | ] 8 | -------------------------------------------------------------------------------- /home/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class HomeConfig(AppConfig): 5 | default_auto_field = "django.db.models.BigAutoField" 6 | name = "home" 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.DS_Store 3 | *.egg* 4 | /dist/ 5 | /.idea 6 | /docs/_build/ 7 | /node_modules/ 8 | build/ 9 | env 10 | /staticfiles/ 11 | 12 | #src 13 | #*.sqlite* 14 | 15 | #.env 16 | node_modules 17 | -------------------------------------------------------------------------------- /home/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse 3 | 4 | # Create your views here. 5 | 6 | def index(request): 7 | 8 | # Page from the theme 9 | return render(request, 'pages/index.html') 10 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # Core 2 | django==4.2.9 3 | python-dotenv==1.0.1 4 | str2bool==1.1 5 | 6 | # UI 7 | django-admin-tabler==1.0.2 8 | 9 | # Deployment 10 | whitenoise==6.6.0 11 | gunicorn==21.2.0 12 | 13 | # psycopg2-binary 14 | # mysqlclient 15 | -------------------------------------------------------------------------------- /env.sample: -------------------------------------------------------------------------------- 1 | # True for development, False for production 2 | DEBUG=True 3 | 4 | SECRET_KEY= 5 | 6 | # DB_ENGINE=mysql 7 | # DB_HOST=localhost 8 | # DB_NAME=appseed_db 9 | # DB_USERNAME=appseed_db_usr 10 | # DB_PASS=pass 11 | # DB_PORT=3306 -------------------------------------------------------------------------------- /gunicorn-cfg.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | """ 3 | Copyright (c) 2019 - present AppSeed.us 4 | """ 5 | 6 | bind = '0.0.0.0:5005' 7 | workers = 1 8 | accesslog = '-' 9 | loglevel = 'debug' 10 | capture_output = True 11 | enable_stdio_inheritance = True 12 | -------------------------------------------------------------------------------- /nginx/appseed-app.conf: -------------------------------------------------------------------------------- 1 | upstream webapp { 2 | server appseed_app:5005; 3 | } 4 | 5 | server { 6 | listen 5085; 7 | server_name localhost; 8 | 9 | location / { 10 | proxy_pass http://webapp; 11 | proxy_set_header Host $host; 12 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9 2 | 3 | # set environment variables 4 | ENV PYTHONDONTWRITEBYTECODE 1 5 | ENV PYTHONUNBUFFERED 1 6 | 7 | COPY requirements.txt . 8 | # install python dependencies 9 | RUN pip install --upgrade pip 10 | RUN pip install --no-cache-dir -r requirements.txt 11 | 12 | COPY . . 13 | 14 | # running migrations 15 | RUN python manage.py migrate 16 | 17 | # gunicorn 18 | CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"] 19 | -------------------------------------------------------------------------------- /core/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for core project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /core/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for core project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /render.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | - type: web 3 | name: django-tabler 4 | plan: starter 5 | env: python 6 | region: frankfurt # region should be same as your database region. 7 | buildCommand: "./build.sh" 8 | startCommand: "gunicorn core.wsgi:application" 9 | envVars: 10 | - key: DEBUG 11 | value: False 12 | - key: SECRET_KEY 13 | generateValue: true 14 | - key: WEB_CONCURRENCY 15 | value: 4 16 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | appseed-app: 4 | container_name: appseed_app 5 | restart: always 6 | build: . 7 | networks: 8 | - db_network 9 | - web_network 10 | nginx: 11 | container_name: nginx 12 | restart: always 13 | image: "nginx:latest" 14 | ports: 15 | - "5085:5085" 16 | volumes: 17 | - ./nginx:/etc/nginx/conf.d 18 | networks: 19 | - web_network 20 | depends_on: 21 | - appseed-app 22 | networks: 23 | db_network: 24 | driver: bridge 25 | web_network: 26 | driver: bridge 27 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /core/urls.py: -------------------------------------------------------------------------------- 1 | """core URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/4.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import include, path 18 | 19 | urlpatterns = [ 20 | path('', include('home.urls')), 21 | path("admin/", admin.site.urls), 22 | path('', include('admin_tabler.urls')), 23 | ] 24 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2019 - present [AppSeed](http://appseed.us/) 4 | 5 |
6 | 7 | ## Licensing Information 8 | 9 |
10 | 11 | | Item | - | 12 | | ---------------------------------- | --- | 13 | | License Type | MIT | 14 | | Use for print | **YES** | 15 | | Create single personal website/app | **YES** | 16 | | Create single website/app for client | **YES** | 17 | | Create multiple website/apps for clients | **YES** | 18 | | Create multiple SaaS applications | **YES** | 19 | | End-product paying users | **YES** | 20 | | Product sale | **YES** | 21 | | Remove footer credits | **YES** | 22 | | --- | --- | 23 | | Remove copyright mentions from source code | NO | 24 | | Production deployment assistance | NO | 25 | | Create HTML/CSS template for sale | NO | 26 | | Create Theme/Template for CMS for sale | NO | 27 | | Separate sale of our UI Elements | NO | 28 | 29 |
30 | 31 | --- 32 | For more information regarding licensing, please contact the AppSeed Service < *support@appseed.us* > 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "appseed-generic", 3 | "version": "1.0.0", 4 | "description": "Generic tooling by AppSeed", 5 | "main": "gulpfile.js", 6 | "author": "AppSeed", 7 | "keywords": [ 8 | "css", 9 | "sass", 10 | "gulp", 11 | "web" 12 | ], 13 | "homepage": "https://appseed.us", 14 | "bugs": { 15 | "email": "support@appseed.us" 16 | }, 17 | "license": "MIT License", 18 | "devDependencies": { 19 | "browser-sync": "^2.27.4", 20 | "del": "^6.0.0", 21 | "gulp": "^4.0.2", 22 | "gulp-autoprefixer": "^8.0.0", 23 | "gulp-clean-css": "^4.3.0", 24 | "gulp-cssbeautify": "^3.0.0", 25 | "node-sass": "^6.0.1", 26 | "gulp-file-include": "^2.3.0", 27 | "gulp-header": "^2.0.9", 28 | "gulp-htmlmin": "^5.0.1", 29 | "gulp-npm-dist": "^1.0.3", 30 | "gulp-plumber": "^1.2.1", 31 | "gulp-rename": "^2.0.0", 32 | "gulp-sass": "^5.0.0", 33 | "gulp-sourcemaps": "^3.0.0", 34 | "gulp-uglify": "^3.0.2", 35 | "gulp-wait": "^0.0.2", 36 | "merge-stream": "^2.0.0" 37 | } 38 | } -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | ========================================================= 4 | * AppSeed - Simple SCSS compiler via Gulp 5 | ========================================================= 6 | 7 | */ 8 | 9 | var autoprefixer = require('gulp-autoprefixer'); 10 | var browserSync = require('browser-sync').create(); 11 | var cleanCss = require('gulp-clean-css'); 12 | var gulp = require('gulp'); 13 | const npmDist = require('gulp-npm-dist'); 14 | var sass = require('gulp-sass')(require('node-sass')); 15 | var wait = require('gulp-wait'); 16 | var sourcemaps = require('gulp-sourcemaps'); 17 | var rename = require("gulp-rename"); 18 | 19 | // Define COMMON paths 20 | 21 | const paths = { 22 | src: { 23 | base: './static', 24 | css: './static/css', 25 | scss: './static/scss', 26 | node_modules: './node_modules/', 27 | vendor: './vendor' 28 | } 29 | }; 30 | 31 | // Compile SCSS 32 | gulp.task('scss', function() { 33 | return gulp.src([paths.src.scss + '/soft-ui-dashboard.scss']) 34 | .pipe(wait(500)) 35 | .pipe(sourcemaps.init()) 36 | .pipe(sass().on('error', sass.logError)) 37 | .pipe(autoprefixer({ 38 | overrideBrowserslist: ['> 1%'] 39 | })) 40 | .pipe(sourcemaps.write('.')) 41 | .pipe(gulp.dest(paths.src.css)) 42 | .pipe(browserSync.stream()); 43 | }); 44 | 45 | // Minify CSS 46 | gulp.task('minify:css', function() { 47 | return gulp.src([ 48 | paths.src.css + '/soft-ui-dashboard.css' 49 | ]) 50 | .pipe(cleanCss()) 51 | .pipe(rename(function(path) { 52 | // Updates the object in-place 53 | path.extname = ".min.css"; 54 | })) 55 | .pipe(gulp.dest(paths.src.css)) 56 | }); 57 | 58 | // Default Task: Compile SCSS and minify the result 59 | gulp.task('default', gulp.series('scss', 'minify:css')); 60 | -------------------------------------------------------------------------------- /templates/pages/sign-up.html: -------------------------------------------------------------------------------- 1 | {% extends 'layouts/base-auth.html' %} 2 | {% load static %} 3 | 4 | {% block title %}Sign up - {% endblock title %} 5 | 6 | {% block content %} 7 | 8 |
9 |
10 |
11 | 12 |
13 |
14 | {% csrf_token %} 15 | 16 | 17 |
18 |

Create new account

19 | {% for field in form %} 20 | {% if not field.name in 'password1, password2' %} 21 |
22 | 23 | {{ field }} 24 | {{ field.errors }} 25 |
26 | {% else %} 27 |
28 | 29 |
30 | {{ field }} 31 | 32 | 33 | 34 | 35 | 36 |
37 | {{ field.errors }} 38 |
39 | {% endif %} 40 | {% endfor %} 41 |
42 | 46 |
47 | 50 |
51 |
52 |
53 | Already have account? Sign in 54 |
55 |
56 |
57 | 58 | {% endblock content %} 59 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [1.0.6] 2024-12-16 4 | ### Changes 5 | 6 | - Preselect the design in the Generator: 7 | - [Django App Generator - Tabler Design](https://app-generator.dev/tools/django-generator/tabler/) 8 | - (Optional) Design Database: edit models and fields 9 | - (Optional) Edit the fields for the extended user model 10 | - (Optional) Enable OAuth for GitHub 11 | - (Optional) Add Celery (async tasks) 12 | - (Optional) Enable Dynamic API Module 13 | - Docker Scripts 14 | - Render CI/Cd Scripts 15 | 16 | **The generated Django project is available as a ZIP Archive and also uploaded to GitHub.** 17 | 18 | ## [1.0.5] 2024-11-27 19 | ### Changes 20 | 21 | > Update RM Links 22 | 23 | - 👉 [Django Tabler](https://app-generator.dev/product/tabler/django/) - `Product Page` 24 | - 👉 [Django Tabler Documentation](https://app-generator.dev/docs/products/django/tabler/index.html) - `Complete Information` and Support Links 25 | - [Getting Started with Django](https://app-generator.dev/docs/technologies/django/index.html) - a `comprehensive tutorial` 26 | - `Configuration`: Install Dependencies, Prepare Environment, Setting up the Database 27 | - `Start with Docker` 28 | - `Manual Build` 29 | - `Start the project` 30 | - `Deploy on Render` 31 | 32 | ## [1.0.4] 2024-03-09 33 | ### Changes 34 | 35 | - Deprecate `distutils` 36 | - use `str2bool` 37 | - Update Deps 38 | - `requirements.txt` 39 | - Update README: [PRO Version](https://appseed.us/product/volt-dashboard-pro/django/), List features 40 | - `API`, **Charts** 41 | - **DataTables** (Filters, Export) 42 | - **Celery** 43 | - **Media Files Manager** 44 | - **Extended User Profiles** 45 | - Update [Custom Development](https://appseed.us/custom-development/) Section 46 | - New Pricing: `$3,999` 47 | 48 | ## [1.0.3] 2023-05-30 49 | ### Changes 50 | 51 | - Update DEMO: [Django Tabler](https://django-tabler.onrender.com/) 52 | - Deployed on `Render` 53 | 54 | ## [1.0.2] 2023-05-29 55 | ### Changes 56 | 57 | - Move to theme-based pattern 58 | - [Django Tabler Admin](https://github.com/app-generator/django-admin-tabler) 59 | - 🚀 `Deployment` 60 | - `CI/CD` flow via `Render` 61 | 62 | ## [1.0.1] 2021-01-20 63 | ### Changes 64 | 65 | - Bump Django Codebase to [v2stable.0.1](https://github.com/app-generator/boilerplate-code-django-dashboard/releases) 66 | - Dependencies update (all packages) 67 | - Django==4.0.1 68 | - Settings update for Django 4.x 69 | - `New Parameter`: CSRF_TRUSTED_ORIGINS 70 | - [Origin header checking isn`t performed in older versions](https://docs.djangoproject.com/en/4.0/ref/settings/#csrf-trusted-origins) 71 | 72 | ## Unreleased 73 | ### Changes 74 | 75 | - Patch [#1 - Whitenoise Fix](https://github.com/app-generator/django-dashboard-tabler/issues/1) 76 | - WhiteNoiseMiddleware must be positioned right after SecurityMiddleware 77 | - Impacted file: [core/settings.py](https://github.com/app-generator/django-dashboard-tabler/blob/master/core/settings.py) / MIDDLEWARE section 78 | 79 | ## [1.0.0] 2020-01-14 80 | ### Changes 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # [Django Tabler](https://app-generator.dev/product/tabler/django/) 3 | 4 | Open-source **Django** project crafted on top of **Tabler Design**, an open-source iconic `Bootstrap` design. 5 | The product is designed to deliver the best possible user experience with highly customizable feature-rich pages. 6 | 7 | - 👉 [Django Tabler](https://app-generator.dev/product/tabler/django/) - `Product Page` 8 | - 👉 [Django Tabler](https://django-tabler.onrender.com/) - `LIVE Demo` 9 | - 👉 [Django Tabler Documentation](https://app-generator.dev/docs/products/django/tabler/index.html) - `Complete Information` and Support Links 10 | - [Getting Started with Django](https://app-generator.dev/docs/technologies/django/index.html) - a `comprehensive tutorial` 11 | - `Configuration`: Install Dependencies, Prepare Environment, Setting up the Database 12 | - `Start with Docker` 13 | - `Manual Build` 14 | - `Start the project` 15 | - `Deploy on Render` 16 | 17 |
18 | 19 | ## 👉 [HOSTINGER](https://www.hostg.xyz/aff_c?offer_id=6&aff_id=207452) - High-quality Service we recommend 20 | 21 | One of the world's fastest-growing hosting providers, **Hostinger** serves a global community of over 4 million website owners across 150+ countries. 22 | **Here are the core services**: 23 | 24 | - ✅ **[HOSTING - $2.99/mo](https://www.hostg.xyz/aff_c?offer_id=6&aff_id=207452)** - 3months FREE 25 | - ✅ **[Website Builder](https://www.hostg.xyz/aff_c?offer_id=6&aff_id=207452&url_id=2949)** - Build Websites in no-time 26 | - ✅ **[eCommerce Builder](https://www.hostg.xyz/aff_c?offer_id=6&aff_id=207452&url_id=4140)** - Your online store, created quickly with AI 27 | - ✅ **[StartUp Cloud Hosting - $7.99/mo](https://www.hostg.xyz/aff_c?offer_id=6&aff_id=207452&url_id=17)** - 3months FREE 28 | 29 |
30 | 31 | ## Features 32 | 33 | - Simple, Easy-to-Extend Codebase 34 | - Tabler Design - Full Integration 35 | - Bootstrap 5 Styling 36 | - Session-based Authentication, Password recovery 37 | - DB Persistence: SQLite (default), can be used with MySql, PgSql 38 | - Docker 39 | - CI/CD integration for Render 40 | 41 | ![Django Dashboard Tabler - Open-Source ](https://github.com/user-attachments/assets/f1fa943d-7e6c-4346-9734-281a8cd2e093) 42 | 43 |
44 | 45 | ## [Material Dashboard PRO Version](https://app-generator.dev/product/material-dashboard-pro/django/) 46 | 47 | > The premium version provides more features, priority on support, and is more often updated - [Live Demo](https://django-material-dash2-pro.onrender.com). 48 | 49 | - **Simple, Easy-to-Extend** Codebase 50 | - **Material Dashboard** Design - PRO Version 51 | - Bootstrap 5 CSS 52 | - **OAuth** - Github 53 | - **Extended User Profile** 54 | - **API** via DRF 55 | - **Charts** via ApexJS 56 | - **Celery** (async tasks) 57 | - **Deployment-Ready** for Render 58 | 59 | ![Django Material Dash2 PRO - Premium starter crafted by App-Generator.](https://github.com/user-attachments/assets/c75c6e67-a940-4d56-9855-070f901ab5ab) 60 | 61 |
62 | 63 | --- 64 | [Django Tabler](https://app-generator.dev/product/tabler/django/) - Open-Source **Django** Starter provided by [App Generator](https://app-generator.dev) 65 | -------------------------------------------------------------------------------- /templates/pages/sign-in.html: -------------------------------------------------------------------------------- 1 | {% extends 'layouts/base-auth.html' %} 2 | {% load static %} 3 | 4 | {% block title %}Sign in - {% endblock title %} 5 | 6 | {% block body %}d-flex flex-column{% endblock body %} 7 | 8 | {% block content %} 9 | 10 |
11 |
12 |
13 | 14 |
15 |
16 |
17 |

Login to your account

18 | 19 |

20 | USER: test / Pass12__ 21 |
22 | ADMIN: admin / Pass12__ 23 |

24 | 25 |
26 | {% csrf_token %} 27 | 28 | {% if form.non_field_errors %} 29 | {% for error in form.non_field_errors %} 30 | {{ error }} 31 | {% endfor %} 32 | {% endif %} 33 | 34 | {% for field in form %} 35 | {% if not field.name == 'password' %} 36 |
37 | 38 | {{ field }} 39 |
40 | {% else %} 41 |
42 | 48 |
49 | {{ field }} 50 | 51 | 52 | 53 | 54 | 55 |
56 |
57 | {% endif %} 58 | {% endfor %} 59 | 60 |
61 | 65 |
66 | 69 |
70 |
71 |
or
72 | 86 |
87 |
88 | Don't have account yet? Sign up 89 |
90 |
91 |
92 | 93 | {% endblock content %} -------------------------------------------------------------------------------- /core/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for core project. 3 | 4 | Generated by 'django-admin startproject' using Django 4.1.2. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.1/ref/settings/ 11 | """ 12 | 13 | import os, random, string 14 | from pathlib import Path 15 | from dotenv import load_dotenv 16 | from str2bool import str2bool 17 | 18 | load_dotenv() # take environment variables from .env. 19 | 20 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 21 | BASE_DIR = Path(__file__).resolve().parent.parent 22 | 23 | # Quick-start development settings - unsuitable for production 24 | # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ 25 | 26 | # SECURITY WARNING: keep the secret key used in production secret! 27 | SECRET_KEY = os.environ.get('SECRET_KEY') 28 | if not SECRET_KEY: 29 | SECRET_KEY = ''.join(random.choice( string.ascii_lowercase ) for i in range( 32 )) 30 | 31 | # Enable/Disable DEBUG Mode 32 | DEBUG = str2bool(os.environ.get('DEBUG')) 33 | #print(' DEBUG -> ' + str(DEBUG) ) 34 | 35 | ALLOWED_HOSTS = ['*'] 36 | 37 | CSRF_TRUSTED_ORIGINS = ['http://localhost:8000', 'http://localhost:5085', 'http://127.0.0.1:8000', 'http://127.0.0.1:5085'] 38 | 39 | RENDER_EXTERNAL_HOSTNAME = os.environ.get('RENDER_EXTERNAL_HOSTNAME') 40 | if RENDER_EXTERNAL_HOSTNAME: 41 | ALLOWED_HOSTS.append(RENDER_EXTERNAL_HOSTNAME) 42 | 43 | # Application definition 44 | 45 | INSTALLED_APPS = [ 46 | 'admin_tabler.apps.AdminTablerConfig', 47 | "django.contrib.admin", 48 | "django.contrib.auth", 49 | "django.contrib.contenttypes", 50 | "django.contrib.sessions", 51 | "django.contrib.messages", 52 | "django.contrib.staticfiles", 53 | 54 | "home", 55 | ] 56 | 57 | MIDDLEWARE = [ 58 | "django.middleware.security.SecurityMiddleware", 59 | "whitenoise.middleware.WhiteNoiseMiddleware", 60 | "django.contrib.sessions.middleware.SessionMiddleware", 61 | "django.middleware.common.CommonMiddleware", 62 | "django.middleware.csrf.CsrfViewMiddleware", 63 | "django.contrib.auth.middleware.AuthenticationMiddleware", 64 | "django.contrib.messages.middleware.MessageMiddleware", 65 | "django.middleware.clickjacking.XFrameOptionsMiddleware", 66 | ] 67 | 68 | ROOT_URLCONF = "core.urls" 69 | 70 | HOME_TEMPLATES = os.path.join(BASE_DIR, 'templates') 71 | 72 | TEMPLATES = [ 73 | { 74 | "BACKEND": "django.template.backends.django.DjangoTemplates", 75 | "DIRS": [HOME_TEMPLATES], 76 | "APP_DIRS": True, 77 | "OPTIONS": { 78 | "context_processors": [ 79 | "django.template.context_processors.debug", 80 | "django.template.context_processors.request", 81 | "django.contrib.auth.context_processors.auth", 82 | "django.contrib.messages.context_processors.messages", 83 | ], 84 | }, 85 | }, 86 | ] 87 | 88 | WSGI_APPLICATION = "core.wsgi.application" 89 | 90 | 91 | # Database 92 | # https://docs.djangoproject.com/en/4.1/ref/settings/#databases 93 | 94 | DB_ENGINE = os.getenv('DB_ENGINE' , None) 95 | DB_USERNAME = os.getenv('DB_USERNAME' , None) 96 | DB_PASS = os.getenv('DB_PASS' , None) 97 | DB_HOST = os.getenv('DB_HOST' , None) 98 | DB_PORT = os.getenv('DB_PORT' , None) 99 | DB_NAME = os.getenv('DB_NAME' , None) 100 | 101 | if DB_ENGINE and DB_NAME and DB_USERNAME: 102 | DATABASES = { 103 | 'default': { 104 | 'ENGINE' : 'django.db.backends.' + DB_ENGINE, 105 | 'NAME' : DB_NAME, 106 | 'USER' : DB_USERNAME, 107 | 'PASSWORD': DB_PASS, 108 | 'HOST' : DB_HOST, 109 | 'PORT' : DB_PORT, 110 | }, 111 | } 112 | else: 113 | DATABASES = { 114 | 'default': { 115 | 'ENGINE': 'django.db.backends.sqlite3', 116 | 'NAME': 'db.sqlite3', 117 | } 118 | } 119 | 120 | # Password validation 121 | # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators 122 | 123 | AUTH_PASSWORD_VALIDATORS = [ 124 | { 125 | "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", 126 | }, 127 | { 128 | "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", 129 | }, 130 | { 131 | "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", 132 | }, 133 | { 134 | "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", 135 | }, 136 | ] 137 | 138 | 139 | # Internationalization 140 | # https://docs.djangoproject.com/en/4.1/topics/i18n/ 141 | 142 | LANGUAGE_CODE = "en-us" 143 | 144 | TIME_ZONE = "UTC" 145 | 146 | USE_I18N = True 147 | 148 | USE_TZ = True 149 | 150 | 151 | # Static files (CSS, JavaScript, Images) 152 | # https://docs.djangoproject.com/en/4.1/howto/static-files/ 153 | 154 | STATIC_URL = '/static/' 155 | STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') 156 | 157 | STATICFILES_DIRS = ( 158 | os.path.join(BASE_DIR, 'static'), 159 | ) 160 | 161 | #if not DEBUG: 162 | # STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' 163 | 164 | # Default primary key field type 165 | # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field 166 | 167 | DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" 168 | 169 | LOGIN_REDIRECT_URL = '/' 170 | EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' 171 | --------------------------------------------------------------------------------