occasionally i get Server Error (500) Missing staticfiles manifest entry

Viewed 24

Before you mark it as duplicate, i did search and go throw many questions https://stackoverflow.com/search?q=[django]+Missing+staticfiles+manifest+entry

my site works, but sometimes i get Server Error (500), And in logs i get: ValueError: Missing staticfiles manifest entry for 'css/jquery-ui.css' it's the first file in base.html.

i think when staticfiles is missing a file, the site should stop at once. in staticfiles.json there is "css/jquery-ui.css": "css/jquery-ui.koi84nfyrp.css",

mysite: storage = s3 cdn = cloudflare django = 4.0.4

P.S: in AWS bill center, there is $0.03 total, but i never get a bill or bay them any.

Error Traceback

ERROR [django.request:241] Internal Server Error: /
Traceback (most recent call last):
  File "/django-my-site/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 220, in _get_response
    response = response.render()
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/response.py", line 114, in render
    self.content = self.rendered_content
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/response.py", line 92, in rendered_content
    return template.render(context, self._request)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/backends/django.py", line 62, in render
    return self.template.render(context)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/base.py", line 175, in render
    return self._render(context)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/django-my-site/venv/lib/python3.8/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/templatetags/static.py", line 116, in render
    url = self.url(context)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/templatetags/static.py", line 113, in url
    return self.handle_simple(path)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/templatetags/static.py", line 129, in handle_simple
    return staticfiles_storage.url(path)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/contrib/staticfiles/storage.py", line 166, in url
    return self._url(self.stored_name, name, force)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/contrib/staticfiles/storage.py", line 145, in _url
    hashed_name = hashed_name_func(*args)
  File "/django-my-site/venv/lib/python3.8/site-packages/django/contrib/staticfiles/storage.py", line 465, in stored_name
    raise ValueError(
ValueError: Missing staticfiles manifest entry for 'css/jquery-ui.css'

settings.py






INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',

    # 3rd Party
    'crispy_forms',
    'crispy_bootstrap5',
    'hitcount',
    'corsheaders',
    'storages',
    'verify_email.apps.VerifyEmailConfig',
    
    # Local apps
    '...'
]

MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    # 'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]



CORS_ORIGIN_WHITELIST = [
    'http://localhost:8000',
    'http://127.0.0.1:8000',

]


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',
    },
]


MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / "media"

STATICFILES_DIRS = [
    BASE_DIR / "static",
]



AWS_ACCESS_KEY_ID = '***'
AWS_SECRET_ACCESS_KEY = '***'
AWS_STORAGE_BUCKET_NAME = '***'  
AWS_REGION_NAME = '***'
AWS_QUERYSTRING_AUTH = False

AWS_S3_OBJECT_PARAMETERS = {
    'CacheControl': 'max-age=86400',
}

AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = 'https://%s/' % AWS_S3_CUSTOM_DOMAIN
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3ManifestStaticStorage'



DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'



0 Answers
Related