This is my pipeline setting:
STATIC_URL = '/static/'
STATIC_ROOT = SETTINGS_DIR + '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static_files"),
)
STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
'compressor.finders.CompressorFinder',
'beautycall.finders.LeftoverPipelineFinder',
)
PIPELINE = {
'JAVASCRIPT': {
'main': {
'source_filenames': (
'bower/jquery/dist/jquery.min.js',
'js/script.js',
),
'output_filename': 'compiled/main_script.js',
},
'datetimepicker': {
'source_filenames': (
'bower/datetimepicker/jquery.datetimepicker.js',
),
'output_filename': 'datetimepicker.js'
},
'typeahead': {
'source_filenames': (
'bower/typeahead.js/dist/bloodhound.js',
'bower/typeahead.js/dist/typeahead.jquery.js',
),
'output_filename': 'typeahead.js'
},
'remodal': {
'source_filenames': (
'bower/remodal/dist/remodal.min.js',
),
'output_filename': 'remodal.js'
}
},
'STYLESHEETS': {
'main': {
'source_filenames': (
'css/style.scss',
'css/fonts.css',
),
'output_filename': 'compiled/main_stylesheet.css',
},
'datetimepicker': {
'source_filenames': (
'bower/datetimepicker/jquery.datetimepicker.css',
),
'output_filename': 'compiled/jquery.datetimepicker.css'
},
'remodal': {
'source_filenames': (
'bower/remodal/dist/remodal.css',
'bower/remodal/dist/remodal-default-theme.css'
),
'output_filename': 'remodal.css'
},
'website': {
'source_filenames': (
'css/website/style.scss',
),
'output_filename': 'compiled/website/style.css',
}
}
}
Its return the error raise CompilerError(e, command=argument_list, pipeline.exceptions.CompilerError: [WinError 2] The system cannot find the file specified. When using custom pipefinder, the pipeline seem to miss all the file in source_filenames. Im using Windows and its no problem when i try it in Linux OS, if its help.
It result in error when running this piece of code on django-pipeline :
compiling = subprocess.Popen(argument_list, cwd=cwd,stdout=stdout,stderr=subprocess.PIPE, shell=False)
At closer look the cwd argument seems fine, but 3 of 4 arguments in argument_list not exist when i checked it with path.exist. Idk if it supposed to be like that or no, neither i am know about subprocess.Popen
Any help much appreciated. Thanks
Related
I want to add new language. it is turkmen (tm) I spent a lot of time but I can't resolve it please help me to resolve it
PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
gettext = lambda s:s
LANGUAGES = (
('ru', gettext('Russia')),
('tm', gettext('Turkmen')),
)
EXTRA_LANG_INFO = {
'tm': {
'bidi': False,
'code': 'tm',
'name': 'Turkmen',
'name_local': u"Turkmence",
},
}
import django.conf.locale
from django.conf import global_settings
import django.conf.locale
LANG_INFO = dict(django.conf.locale.LANG_INFO, **EXTRA_LANG_INFO)
django.conf.locale.LANG_INFO = LANG_INFO
global_settings.LANGUAGES = global_settings.LANGUAGES + [("tm", 'Turkmenche')]
1.install gettext
django-admin makemessages -l tm
django-admin compilemessages
This is my settings.py file and I've created a .env file which contains secret key and other stuffs. I tried installing reinstalling python changing path deleting and again adding project and even I reinstalled vs code but it won't work i dont know where's the problem. This command python manage.py runserver or python manage.py shell or any other related commmand won't work
"""Settings.py"""
"""
Django settings for doorstepdelhi project.
Generated by 'django-admin startproject' using Django 3.1.7.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from decouple import config
import django_heroku
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/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config("DEBUG", default=False, cast=bool)
ALLOWED_HOSTS = ["localhost", "127.0.0.1"]
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'django.contrib.sites',
'allauth',
'allauth.account',
'rest_auth.registration',
"versatileimagefield",
"nested_admin",
'drf_yasg',
"django_extensions",
'channels',
"accounts",
"webtraffic",
"store",
"product",
"shop",
"wishlist",
"payment",
'core',
"room",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"core.middleware.LogMiddleware",
]
ROOT_URLCONF = "doorstepdelhi.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 = "doorstepdelhi.wsgi.application"
ASGI_APPLICATION = 'doorstepdelhi.asgi.application'
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('127.0.0.1', 6379)],
},
},
}
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Password validation
# https://docs.djangoproject.com/en/3.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/3.1/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "Asia/Kolkata"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = "/static/"
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, "static")
CORS_ORIGIN_ALLOW_ALL = True
SITE_ID = 1
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_DECIMAL_PLACES = 3
DEFAULT_MAX_DIGITS = 12
REST_FRAMEWORK = {
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.AllowAny",),
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework.authentication.TokenAuthentication",
"rest_framework.authentication.SessionAuthentication",
),
"DEFAULT_FILTER_BACKENDS": ["django_filters.rest_framework.DjangoFilterBackend"],
"DATETIME_FORMAT": "%b %d %Y %H:%M:%S",
}
CSRF_COOKIE_NAME = "csrftoken"
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_EMAIL_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = "username"
ACCOUNT_EMAIL_VERIFICATION = "optional"
ACCOUNT_USERNAME_REQUIRED = True
AUTH_USER_MODEL = "accounts.User"
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
EMAIL_URL = os.environ.get("EMAIL_URL")
SENDGRID_USERNAME = os.environ.get("SENDGRID_USERNAME")
SENDGRID_PASSWORD = os.environ.get("SENDGRID_PASSWORD")
if not EMAIL_URL and SENDGRID_USERNAME and SENDGRID_PASSWORD:
EMAIL_URL = "smtp://%s:%s#smtp.sendgrid.net:587/?tls=True" % (
SENDGRID_USERNAME,
SENDGRID_PASSWORD,
)
REST_AUTH_SERIALIZERS = {
"USER_DETAILS_SERIALIZER": "accounts.serializers.UserSerializer",
}
VERSATILEIMAGEFIELD_RENDITION_KEY_SETS = {
"products": [
("product_gallery", "thumbnail__540x540"),
("product_gallery_2x", "thumbnail__1080x1080"),
("product_small", "thumbnail__60x60"),
("product_small_2x", "thumbnail__120x120"),
("product_list", "thumbnail__255x255"),
("product_list_2x", "thumbnail__510x510"),
],
"background_images": [("header_image", "thumbnail__1080x440")],
"user_avatars": [("default", "thumbnail__445x445")],
}
# VERSATILEIMAGEFIELD_SETTINGS = {
# # Images should be pre-generated on Production environment
# "create_images_on_demand": get_bool_from_env("CREATE_IMAGES_ON_DEMAND", DEBUG)
# }
PLACEHOLDER_IMAGES = {
60: "images/placeholder60x60.png",
120: "images/placeholder120x120.png",
255: "images/placeholder255x255.png",
540: "images/placeholder540x540.png",
1080: "images/placeholder1080x1080.png",
}
# EMAIL
EMAIL_USE_TLS = config("EMAIL_USE_TLS")
EMAIL_USE_SSL = config("EMAIL_USE_SSL")
EMAIL_HOST = config("EMAIL_HOST")
EMAIL_PORT = config("EMAIL_PORT")
EMAIL_HOST_USER = config("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = config("EMAIL_HOST_PASSWORD")
DEFAULT_FROM_EMAIL = config("DEFAULT_FROM_EMAIL")
# CELERY
CELERY_BROKER_URL = os.environ.get("CELERY_BROKER", "redis://redis:6379/0")
CELERY_RESULT_BACKEND = os.environ.get("CELERY_BROKER", "redis://redis:6379/0")
# CELERY_TIMEZONE = 'Asia/Kolkata'
# CELERY_TASK_TRACK_STARTED = True
# CELERY_TASK_TIME_LIMIT = 30 * 60
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://redis:6379/0",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
},
"KEY_PREFIX": "doorstepdelhi",
}
}
django_heroku.settings(locals())
PAYTM_MERCHANT_ID = config("PAYTM_MERCHANT_ID")
PAYTM_SECRET_KEY = config("PAYTM_SECRET_KEY")
PAYTM_WEBSITE = config("PAYTM_WEBSITE")
PAYTM_CHANNEL_ID = config("PAYTM_CHANNEL_ID")
PAYTM_INDUSTRY_TYPE_ID = config("PAYTM_INDUSTRY_TYPE_ID")
This is the manage.py file
#!/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", "doorstepdelhi.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()
This is "where python" output
C:\Users\hp>where python
C:\Users\hp\AppData\Local\Programs\Python\Python39\python.exe
C:\Users\hp\Desktop\New folder\Doorstep-Delhi-Back-end\venv\Scripts\python.exe
I am trying to add a simple bar chart to my app but while going through a tutorial, I've added in the bottom portion to my Settings.py code and now my app will not load at all. I've tried adjusting this line to just 'routing.application' and moving it to the bottom of my code but neither has worked. Any thoughts?
Error:
Traceback (most recent call last):
File "C:\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Python38\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Python38\lib\site-packages\channels\management\commands\runserver.py", line 107, in inner_run
application=self.get_application(options),
File "C:\Python38\lib\site-packages\channels\management\commands\runserver.py", line 132, in get_application
return StaticFilesWrapper(get_default_application())
File "C:\Python38\lib\site-packages\channels\routing.py", line 30, in get_default_application
raise ImproperlyConfigured("Cannot import ASGI_APPLICATION module %r" % path)
django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'django_dash.routing
Settings.py
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 3.1.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'x'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'channels',
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_plotly_dash.apps.DjangoPlotlyDashConfig',
'bootstrap4',
'dpd_static_support',
]
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',
# Adding additional MIDDLEWARE
'whitenoise.middleware.WhiteNoiseMiddleware',
'django_plotly_dash.middleware.BaseMiddleware',
'django_plotly_dash.middleware.ExternalRedirectionMiddleware',
]
ROOT_URLCONF = 'mysite.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',
],
},
},
]
WSGI_APPLICATION = 'mysite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.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/3.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/3.1/howto/static-files/
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_URL = '/static/'
X_FRAME_OPTIONS = 'SAMEORIGIN'
#
# Define folder location of 'static' folder
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# 'django_dash': django app name
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'django_dash', 'static'),
]
# Static content of Plotly components that should
# be handled by the Django staticfiles infrastructure
PLOTLY_COMPONENTS = [
'dash_core_components',
'dash_html_components',
'dash_bootstrap_components',
'dash_renderer',
'dpd_components',
'dpd_static_support',
]
# Staticfiles finders for locating dash app assets and related files (Dash static files)
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django_plotly_dash.finders.DashAssetFinder',
'django_plotly_dash.finders.DashComponentFinder',
'django_plotly_dash.finders.DashAppDirectoryFinder',
]
# Channels config, to use channel layers
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
'hosts': [('127.0.0.1', 6379),],
},
},
}
# Adding ASGI Application
ASGI_APPLICATION = 'django_dash.routing.application'
# ---------- Add Django Dash end --------------------------------
Dash Visual:
import dash
import dash_core_components as dcc
import dash_html_components as html
from django_plotly_dash import DjangoDash
# Read plotly example dataframe to plot barchart
import plotly.express as px
df = px.data.gapminder().query("country=='India'")
external_stylesheets=['https://codepen.io/amyoshino/pen/jzXypZ.css']
# Important: Define Id for Plotly Dash integration in Django
app = DjangoDash('dash_integration_id')
app.css.append_css({
"external_url": external_stylesheets
})
app.layout = html.Div(
html.Div([
# Adding one extar Div
html.Div([
html.H1(children='Multiple Application'),
html.H3(children='Indian Population over time'),
html.Div(children='Dash: Python framework to build web application'),
], className = 'row'),
html.Div([
html.Div([
dcc.Graph(
id='bar-chart',
figure={
'data': [
{'x': df['year'], 'y': df['pop'], 'type': 'bar', 'name': 'SF'},
],
'layout': {
'title': 'Bar Chart Visualization'
}
}
),
], className = 'six columns'),
# Adding one more app/component
html.Div([
dcc.Graph(
id='line-chart',
figure={
'data': [
{'x': df['year'], 'y': df['pop'], 'type': 'line', 'name': 'SF'},
],
'layout': {
'title': 'Line Chart Visualization'
}
}
)
], className = 'six columns')
], className = 'row')
])
)
if __name__ == '__main__':
app.run_server(8052, debug=False)
As soon as I defined 'STYLESHEET' in my PIPELINE and did run python3 manage.py collectstatic, I got the
django.core.exceptions.SuspiciousFileOperation: The joined path (/) is located outside of the base path component (/opt/luciapp/apps/web/lapp-web-site/src/apps/main/frontend/static)
I'm sure it's nothing to do with my STATICFILES_DIRS or the STATIC_ROOT
I'm an intermediate in Django Dev and surely a noob in front-end, Please help me with this.
I've attached the snippets of the error log as well as the settings snippet
(website) ➜ src git:(clean_for_production) ✗ python3 manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings:
/opt/luciapp/apps/web/lapp-web-site/public
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 188, in handle
collected = self.collect()
File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 128, in collect
for original_path, processed_path, processed in processor:
File "/usr/local/lib/python3.7/site-packages/pipeline/storage.py", line 26, in post_process
packager.pack_stylesheets(package)
File "/usr/local/lib/python3.7/site-packages/pipeline/packager.py", line 100, in pack_stylesheets
variant=package.variant, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pipeline/packager.py", line 114, in pack
package.paths,
File "/usr/local/lib/python3.7/site-packages/pipeline/packager.py", line 34, in paths
return [path for path in self.sources
File "/usr/local/lib/python3.7/site-packages/pipeline/packager.py", line 27, in sources
if path not in paths and find(path):
File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/finders.py", line 263, in find
result = finder.find(path, all=all)
File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/finders.py", line 98, in find
matched_path = self.find_location(root, path, prefix)
File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/finders.py", line 115, in find_location
path = safe_join(root, path)
File "/usr/local/lib/python3.7/site-packages/django/utils/_os.py", line 49, in safe_join
'component ({})'.format(final_path, base_path))
django.core.exceptions.SuspiciousFileOperation: The joined path (/) is located outside of the base path component (/opt/luciapp/apps/web/lapp-web-site/src/apps/main/frontend/static)
**Here goes the snippet of settings: **
# Static
STATIC_ROOT = os.path.join(PROJECT_DIR, 'public')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'apps', 'main', 'frontend', 'static'),
)
# Pipeline Stack
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
)
# Django-Pipeline
PIPELINE = {
'PIPELINE_ENABLED': True, # TODO: not settings.DEBUG
'DISABLE_WRAPPER': True,
'CSS_COMPRESSOR': 'pipeline.compressors.yuglify.YuglifyCompressor',
'JS_COMPRESSOR': 'pipeline.compressors.yuglify.YuglifyCompressor',
'STYLESHEETS': {
'vendor': {
'source_filenames': (
'vendor/fontawesome/css/all.css'
),
'output_filename': 'assets/css/vendor.min.css',
'extra_context': {
'media': 'all'
}
}
},
'JAVASCRIPT': {
'vendor': {
'source_filenames': (
'vendor/theme/js/core/jquery.min.js',
'vendor/theme/js/core/popper.min.js',
'vendor/theme/js/core/bootstrap-material-design.min.js',
),
'output_filename': 'assets/js/vendor.min.js',
'extra_context': {
'defer': 'defer'
}
},
'common': {
'source_filenames': (
'assets/js/common.js',
),
'output_filename': 'assets/js/common.min.js',
'extra_context': {
'defer': 'defer'
}
},
'index': {
'source_filenames': (
'assets/js/index.js',
),
'output_filename': 'assets/js/index.min.js',
# 'extra_context': {
# 'defer': 'defer'
# }
},
}
}
Versions:
Python==3.7.4
jinja2==2.10.3 # Jinja Templating
django-pipeline==1.6.14 # Django Pipeline for CSS, HTML
django-htmlmin==0.11.0 # Django HTML Minifier
Thanks, Again!
EDIT 2:
The issue has been solved as per the new PIPELINE Declaration. I missed a comma PIPELINE.STYLESHEETS.vendor.source_filenames
# Django-Pipeline
PIPELINE = {
'PIPELINE_ENABLED': True, # TODO: not settings.DEBUG
'DISABLE_WRAPPER': True,
'CSS_COMPRESSOR': 'pipeline.compressors.yuglify.YuglifyCompressor',
'JS_COMPRESSOR': 'pipeline.compressors.yuglify.YuglifyCompressor',
'STYLESHEETS': {
'vendor': {
'source_filenames': (
'vendor/fontawesome/css/all.css',
),
'output_filename': 'assets/css/vendor.min.css',
'extra_context': {
'media': 'all'
}
}
},
'JAVASCRIPT': {
'vendor': {
'source_filenames': (
'vendor/theme/js/core/jquery.min.js',
'vendor/theme/js/core/popper.min.js',
'vendor/theme/js/core/bootstrap-material-design.min.js',
),
'output_filename': 'assets/js/vendor.min.js',
'extra_context': {
'defer': 'defer'
}
},
'common': {
'source_filenames': (
'assets/js/common.js',
),
'output_filename': 'assets/js/common.min.js',
'extra_context': {
'defer': 'defer'
}
},
'index': {
'source_filenames': (
'assets/js/index.js',
),
'output_filename': 'assets/js/index.min.js',
# 'extra_context': {
# 'defer': 'defer'
# }
},
}
}
I have installed Sentry(6.3.2)/Raven(3.5.1) to monitor my Django 1.5.5 application, which works if I have my application on DEBUG=True in my settings.py. However, if I set it to False, no more error messages arrive at Sentry. My Raven application definitely works when tested with "python manage.py raven test"(in addition to the error messages that arrive when running Django in Debug-mode).
Sentry runs in a different virtualenvironment from my Django application and they both run through an Nginx reverse-proxy. I am running python 2.6.
My settings.py looks like this:
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ADMINS = (
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'my_db', # Or path to database file if using sqlite3.
'USER': 'my_db_user', # Not used with sqlite3.
'PASSWORD': 'my_db_pw', # Not used with sqlite3.
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = "my_mail#my_provider.com"
EMAIL_HOST_PASSWORD = "my_password"
EMAIL_PORT = 25
EMAIL_USE_TLS = True
ALLOWED_HOSTS = ['my_domain', 'localhost']
TIME_ZONE = 'Europe/Zurich'
LANGUAGE_CODE = 'de-ch'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
USE_THOUSAND_SEPARATOR = True
FORMAT_MODULE_PATH = 'my_app.formats'
MEDIA_ROOT = ''
MEDIA_URL = '/media/'
STATIC_ROOT = '/path/to/static'
STATIC_URL = 'http://myip/static/'
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
SECRET_KEY = 'my_secret_key'
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
)
TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.request",
"django.contrib.messages.context_processors.messages")
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
ROOT_URLCONF = 'my_app.urls'
WSGI_APPLICATION = 'my_app.wsgi.application'
TEMPLATE_DIRS = (
'/paht/to/templates',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
'django_extensions',
'south',
'django.contrib.admin',
'raven.contrib.django.raven_compat',
)
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'root': {
'level': 'WARNING',
'handlers': ['sentry'],
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
},
'handlers': {
'sentry': {
'level': 'ERROR',
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'django.db.backends': {
'level': 'ERROR',
'handlers': ['console'],
'propagate': False,
},
'raven': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
},
'sentry.errors': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
},
},
}
RAVEN_CONFIG = {
'dsn': 'http://some_code#www.my_domain.com/sentry/2',
}
and my sentry.conf.py like this:
from sentry.conf.server import *
import os.path
CONF_ROOT = os.path.dirname(__file__)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'my_sentry_db',
'USER': 'my_sentry_db_user',
'PASSWORD': 'my_sentry_db_pw',
'HOST': 'localhost',
'PORT': '',
}
}
SENTRY_URL_PREFIX = '/sentry'
FORCE_SCRIPT_NAME = '/sentry'
ALLOWED_HOSTS = ['www.my_domain.com', 'localhost', '127.0.0.1:9002']
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SENTRY_WEB_HOST = '0.0.0.0'
SENTRY_WEB_PORT = 9002
SENTRY_WEB_OPTIONS = {
'workers': 3, # the number of gunicorn workers
'secure_scheme_headers': {'X-FORWARDED-PROTO': 'https'},
}
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_HOST_PASSWORD = ''
EMAIL_HOST_USER = ''
EMAIL_PORT = 25
EMAIL_USE_TLS = False
SERVER_EMAIL = 'root#sentry'
SECRET_KEY = 'my_secret_key'
TWITTER_CONSUMER_KEY = ''
TWITTER_CONSUMER_SECRET = ''
FACEBOOK_APP_ID = ''
FACEBOOK_API_SECRET = ''
GOOGLE_OAUTH2_CLIENT_ID = ''
GOOGLE_OAUTH2_CLIENT_SECRET = ''
GITHUB_APP_ID = ''
GITHUB_API_SECRET = ''
TRELLO_API_KEY = ''
TRELLO_API_SECRET = ''
BITBUCKET_CONSUMER_KEY = ''
BITBUCKET_CONSUMER_SECRET = ''
How can I get Raven/Sentry to run when not in Debug mode with Django?
Thanks so much in advance for your help!
Update:
I just wanted to add, that I do receive the "SuspiciousOperation: Invalid HTTP_ HOST header (you may need to set ALLOWED_ HOSTS)" error message on Sentry, even when the debug-mode is off.
The majority of these messages comes from the fact that I have removed one of my former domains from my ALLOWED_HOSTS list and bots are still looking for it.
And just to clarify: The messages I am not receiving in non-debug-mode are the ones where I put an "assert False" into my code or just type in some random string to throw me an error.