Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SECRET_KEY is required for collectstatic #743

Open
Jeanbouvatt opened this issue Jul 30, 2024 · 0 comments
Open

SECRET_KEY is required for collectstatic #743

Jeanbouvatt opened this issue Jul 30, 2024 · 0 comments

Comments

@Jeanbouvatt
Copy link

Somewhere along my build process, I collect static to copy them to a nginx static file server.

# In a dockerfile
RUN python manage.py collectstatic --settings=core.settings.production --noinput

core/settings/production.py does not have a fixed SECRET_KEY defined, it refers to env var thus it crashes.

$ poetry run python manage.py collect-static --settings=core.settings.production
[...]
    from django_q.conf import Conf
  File "/.../python3.12/site-packages/django_q/conf.py", line 42, in <module>
    class Conf:
  File "/.../python3.12/site-packages/django_q/conf.py", line 209, in Conf
    SECRET_KEY = settings.SECRET_KEY
                 ^^^^^^^^^^^^^^^^^^^
  File "/.../python3.12/site-packages/django/conf/__init__.py", line 111, in __getattr__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

Having to define the SECRET_KEY in the build process feels very wrong. As such I cannot have a single image to be deployed multiple times if this SECRET_KEY is truly used.

Our simple solution is to set this var:

RUN SECRET_KEY=notimportant python manage.py collectstatic --settings=core.settings.production --noinput

however I am afraid that this SECRET_KEY might be used somewhere around there.

Could we envision a django_q that would not requires this SECRET_KEY in such step, i.e only when needed at runtime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant