141 lines
3.5 KiB
Python
141 lines
3.5 KiB
Python
"""
|
|
Django settings for netbox project.
|
|
|
|
Generated by 'django-admin startproject' using Django 1.8.2.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/1.8/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/1.8/ref/settings/
|
|
"""
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
import os
|
|
import socket
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
# Application definition
|
|
INSTALLED_APPS = (
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'corsheaders',
|
|
'debug_toolbar',
|
|
'django_extensions',
|
|
'django_tables2',
|
|
'rest_framework',
|
|
'rest_framework_swagger',
|
|
'circuits',
|
|
'dcim',
|
|
'ipam',
|
|
'extras',
|
|
'secrets',
|
|
'users',
|
|
'utilities',
|
|
)
|
|
|
|
MIDDLEWARE_CLASSES = (
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'utilities.middleware.LoginRequiredMiddleware',
|
|
)
|
|
|
|
ROOT_URLCONF = 'netbox.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [BASE_DIR + '/templates/'],
|
|
'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',
|
|
'utilities.context_processors.settings',
|
|
'django.core.context_processors.request',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'netbox.wsgi.application'
|
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/1.8/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/1.8/howto/static-files/
|
|
STATIC_URL = '/static/'
|
|
STATICFILES_DIRS = (
|
|
os.path.join(BASE_DIR, "project-static"),
|
|
)
|
|
|
|
# Messages
|
|
from django.contrib.messages import constants as messages
|
|
MESSAGE_TAGS = {
|
|
messages.ERROR: 'danger',
|
|
}
|
|
|
|
# Pagination
|
|
PAGINATE_COUNT = 50
|
|
|
|
# Authentication
|
|
LOGIN_URL = '/login/'
|
|
LOGIN_REDIRECT_URL = '/'
|
|
LOGOUT_URL = '/logout/'
|
|
|
|
# Default time formats
|
|
DATE_FORMAT = 'N j, Y'
|
|
SHORT_DATE_FORMAT = 'Y-m-d'
|
|
TIME_FORMAT = 'g:i:s a'
|
|
SHORT_TIME_FORMAT = 'H:i:s'
|
|
DATETIME_FORMAT = 'N j, Y \a\t g:i a'
|
|
SHORT_DATETIME_FORMAT = 'Y-m-d H:i'
|
|
|
|
# Secrets
|
|
SECRETS_MIN_PUBKEY_SIZE = 2048
|
|
|
|
# Django REST framework
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',)
|
|
}
|
|
|
|
try:
|
|
HOSTNAME = socket.gethostname()
|
|
except:
|
|
HOSTNAME = 'localhost'
|
|
|
|
# Import local configuration
|
|
try:
|
|
from configuration import *
|
|
except ImportError:
|
|
pass
|
|
|
|
# django-cors-headers (API Cross-Origin Resource Sharing)
|
|
if DEBUG:
|
|
CORS_ORIGIN_ALLOW_ALL = True
|
|
CORS_ALLOW_METHODS = (
|
|
'GET',
|
|
'OPTIONS',
|
|
)
|