Related
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
I have tried all the solutions I have seen, but I am still having the same error. I am trying to populate my database with some fake data generated in the file below:
population_madlibs_app.py
import random
from madlibs_app.models import User
from faker import Faker
import django
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'madlibs_project.settings')
django.setup()
fakegen = Faker()
fname = ['Charles', 'Stephen', 'Mike', 'Cornell', 'John', 'Yemi', 'Tomiwa']
lname = ['Nurudeen', 'Ayotunde', 'Ajiteru',
'Kolade', 'Babatunde', 'Ifeanyi', 'Ola']
email_client = ['yahoo.com', 'gmail.com', 'outlook.com']
def add_user():
fname = random.choice(fname)
lname = random.choice(lname)
emailed = '{}.{}#{}'.format(fname, lname, random.choice(email_client))
ur = User.objects.get_or_create(
first_name=fname, last_name=lname, email=emailed)[0]
ur.save()
return ur
def populate(n=1):
for entry in range(n):
create_user = add_user()
if __name__ == '__main__':
print('Processing...')
populate(10)
print('Succesfully created!')
But I keep getting the following error:
Traceback (most recent call last):
File "C:\Users\Madlibs\Desktop\madlibs\madlibs_project\population_madlibs_app.py", line 2, in <module>
from madlibs_app.models import User
File "C:\Users\Madlibs\Desktop\madlibs\madlibs_project\madlibs_app\models.py", line 6, in <module>
class User(models.Model):
File "C:\Users\Madlibs\anaconda3\envs\madlibs\lib\site-packages\django\db\models\base.py", line 127, in __new__
app_config = apps.get_containing_app_config(module)
File "C:\Users\Madlibs\anaconda3\envs\madlibs\lib\site-packages\django\apps\registry.py", line 260, in get_containing_app_config
self.check_apps_ready()
File "C:\Users\Madlibs\anaconda3\envs\madlibs\lib\site-packages\django\apps\registry.py", line 138, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
I have checked and seen several solutions, including the set DJANGO_SETTINGS_MODULE=madlibs_project.settings in cmd virtual env but still no solution.
This is my settings.py file.
"""
Django settings for madlibs_project project.
Generated by 'django-admin startproject' using Django 4.1.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
TEMPLATE_DIR = Path.joinpath(BASE_DIR, "templates")
STATIC_DIR = Path.joinpath(BASE_DIR, "static")
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-t-pby#4p3a%mpz2r_w3)d(7msdnrx#wl-yolws*hu5&owb7jq%"
# 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",
"madlibs_app.apps.MadlibsAppConfig",
]
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 = "madlibs_project.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [TEMPLATE_DIR],
"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 = "madlibs_project.wsgi.application"
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Password validation
# https://docs.djangoproject.com/en/4.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/4.1/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/4.1/howto/static-files/
STATIC_URL = "static/"
STATICFILES_DIRS = [
STATIC_DIR,
]
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
The problem is because you are trying to import a model before django.setup().
Try to change your code to this, note django.set() is moved before importing the model.
import django
import random
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'madlibs_project.settings')
django.setup()
from madlibs_app.models import User
from faker import Faker
fakegen = Faker()
fname = ['Charles', 'Stephen', 'Mike', 'Cornell', 'John', 'Yemi', 'Tomiwa']
lname = ['Nurudeen', 'Ayotunde', 'Ajiteru',
'Kolade', 'Babatunde', 'Ifeanyi', 'Ola']
email_client = ['yahoo.com', 'gmail.com', 'outlook.com']
def add_user():
fname = random.choice(fname)
lname = random.choice(lname)
emailed = '{}.{}#{}'.format(fname, lname, random.choice(email_client))
ur = User.objects.get_or_create(
first_name=fname, last_name=lname, email=emailed)[0]
ur.save()
return ur
def populate(n=1):
for entry in range(n):
create_user = add_user()
if __name__ == '__main__':
print('Processing...')
populate(10)
print('Succesfully created!')
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
when I run python manage.py runserver
and I try to visit my site on my local I get the following error:
File "/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/backend/virtualsuits/local/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 432, in stored_name
raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
ValueError: Missing staticfiles manifest entry for 'inline.bundle.js'
my settings file in full:
"""
Django settings for suitsandtables project.
Generated by 'django-admin startproject' using Django 1.11.10.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
from decouple import config, Csv
import datetime
# 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/1.11/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=True, cast=bool)
DEBUG_PROPAGATE_EXCEPTIONS = config('DEBUG_PROPAGATE_EXCEPTIONS', default=True, cast=bool)
BLOCKEMAIL = config('BLOCKEMAIL', default=True, cast=bool)
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv())
# send grid email code
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = config('EMAIL_USE_TLS', default=True, cast=bool)
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_PORT = config('EMAIL_PORT')
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
# Amazon S3 code
AWS_UPLOAD_BUCKET = config('AWS_UPLOAD_BUCKET')
AWS_UPLOAD_USERNAME = config('AWS_UPLOAD_USERNAME')
AWS_UPLOAD_GROUP = config('AWS_UPLOAD_GROUP')
AWS_UPLOAD_ROOT_URI = config('AWS_UPLOAD_ROOT_URI')
# Google maps geocode api url and key
googlemapsgeocodeurl = config('googlemapsgeocodeurl')
googlemapsgeocodekey = config('googlemapsgeocodekey')
googlemapsembedbaseurl = config('googlemapsembedbaseurl')
#example request https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY
emaillinks = {
'devroot': 'localhost:4200/',
'devserverroot': 'http://suitsandtables3.herokuapp.com/',
'productionroot': 'http://www.suitsandtables.com/',
'venueuserverify': 'user/venue/validate/',
'clientuserverify': 'user/client/validate/',
'suitsuserverify': 'user/suits/validate/',
'forgotpassword': 'user/forgot-password/validate/'
}
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'rest_framework',
'storages',
'venues',
'suitsandtablessettingsapp',
'Requestforproposal',
'rest_framework_jwt',
'STuser'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'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 = 'suitsandtables.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['suitsandtables/templates',
'stemail/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 = 'suitsandtables.wsgi.application'
AUTH_USER_MODEL = 'STuser.STUser'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': config('DBNAME'),
'USER': config('DBUSER'),
'PASSWORD': config('DBPASSWORD'),
'HOST': config('DBHOST'),
'PORT': config('DBPORT'),
}
}
#REST Framework
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES':(
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
),
}
#JWT settings
JWT_AUTH = {
'JWT_ENCODE_HANDLER':
'rest_framework_jwt.utils.jwt_encode_handler',
'JWT_DECODE_HANDLER':
'rest_framework_jwt.utils.jwt_decode_handler',
'JWT_PAYLOAD_HANDLER':
'rest_framework_jwt.utils.jwt_payload_handler',
'JWT_PAYLOAD_GET_USER_ID_HANDLER':
'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler',
'JWT_RESPONSE_PAYLOAD_HANDLER':
'rest_framework_jwt.utils.jwt_response_payload_handler',
'JWT_SECRET_KEY': SECRET_KEY,
'JWT_GET_USER_SECRET_KEY': None,
'JWT_PUBLIC_KEY': None,
'JWT_PRIVATE_KEY': None,
'JWT_ALGORITHM': 'HS256',
'JWT_VERIFY': False,
'JWT_VERIFY_EXPIRATION': False,
'JWT_LEEWAY': 0,
'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=20),
'JWT_AUDIENCE': None,
'JWT_ISSUER': None,
'JWT_ALLOW_REFRESH': True,
'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=30),
'JWT_AUTH_HEADER_PREFIX': 'JWT',
'JWT_AUTH_COOKIE': None,
}
# Password validation
# https://docs.djangoproject.com/en/1.11/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/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
#angular distro root
ANGULAR_APP_DIR = os.path.join(BASE_DIR, 'frontend/dist/')
#image distro root
ASSETS_DIR = os.path.join(BASE_DIR, 'frontend/dist/assets/')
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
#STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
#STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(ANGULAR_APP_DIR),
os.path.join(ASSETS_DIR),
]
What I don't understand is why is this file failing? This is from an angular 6 project. What is the best way to debug this?
I can see the file in my static file directory after collect static is ran, and it looks from other posts this is a white noise issue.
I used a conventional static file directory rather than white noise as a test and the problem still persisted.
debug = false and STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' == CRASH
debug = false and STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' == 200_ok
Also, be sure and update to whitenoise v4+ and read the docs. It is not backwards-compatible with older versions or settings!
I'm trying to add site translations for a few African languages that Django 1.6.8 does not support. I don't need the admin to to work in those languages, but I do need to support them.
My site already has working translations in 25 languages from languages officially supported by Django and they are divided by subdomain, so de.mysite.com is German. I'm using subdomain middleware to set the locale based on the subdomain, like so:
class SubDomainLanguage(object):
def process_request(self, request):
prefix = None
try:
prefix = request.META['HTTP_HOST'].split('.')[0]
if prefix == 'no':
prefix = 'nb'
request.session['django_language'] = prefix
except KeyError:
pass
if not prefix:
request.session['django_language'] = 'en'
Various web searches have led me to a point where it feels like I'm close to adding support for these languages, but visiting yo.mysite.com gives me the English version of the site, so something's missing (de.mysite.com is in German, as intended).
Yoruba translations exist in locale/yo/LC_MESSAGES/django.mo and django.po, and python manage.py compilemessages worked fine.
Here are the related lines from my settings.py file:
from django.conf import global_settings
from django.utils.translation import gettext_noop
MIDDLEWARE_CLASSES = (
...
'subdomainmiddleware.SubDomainLanguage',
'django.middleware.locale.LocaleMiddleware',
...
)
global_settings.LANGUAGES += ('ak', gettext_noop('Akan'))
global_settings.LANGUAGES += ('ig', gettext_noop('Igbo'))
global_settings.LANGUAGES += ('rw', gettext_noop('Rwanda'))
global_settings.LANGUAGES += ('sn', gettext_noop('Shona'))
global_settings.LANGUAGES += ('yo', gettext_noop('Yoruba'))
global_settings.LANGUAGES += ('zu', gettext_noop('Zulu'))
EXTRA_LANG_INFO = {
'ak': {
'bidi': False,
'code': 'ak',
'name': 'Akan',
'name_local': u'Akan'
},
'ig': {
'bidi': False,
'code': 'ig',
'name': 'Igbo',
'name_local': u'Asụsụ Igbo'
},
'rw': {
'bidi': False,
'code': 'rw',
'name': 'Rwanda',
'name_local': u'Kinyarwanda'
},
'sn': {
'bidi': False,
'code': 'sn',
'name': 'Shona',
'name_local': u'chiShona'
},
'yo': {
'bidi': False,
'code': 'yo',
'name': 'Yoruba',
'name_local': u'èdè Yorùbá'
},
'zu': {
'bidi': False,
'code': 'zu',
'name': 'Zulu',
'name_local': u'isiZulu'
},
}
import django.conf.locale
LANG_INFO = dict(django.conf.locale.LANG_INFO.items() + EXTRA_LANG_INFO.items())
django.conf.locale.LANG_INFO = LANG_INFO
What could be missing? Or is there maybe something in the wrong order?