27π
β
I managed to fix it.
I created another directory in my project folder called static and copied my static files there.
I then added:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
import settings
if settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()
to my urls.py
and
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
to my settings.py
.
Then, when I deploy I execute manage.py collectstatic
and since Apache is configured properly, everything will work!
Based on http://dlo.me/archives/2013/01/14/how-to-serve-static-files-django/
Thanks to all.
π€Meir
10π
I usually run python manage.py runserver --insecure
to force serving of static files with the staticfiles app even if the DEBUG setting is False.
Hereβs the link of their documentation. https://docs.djangoproject.com/en/3.2/ref/contrib/staticfiles/#cmdoption-runserver-insecure
π€Zeno
- [Django]-How to get 'switch-case' statement functionality in Django templates?
- [Django]-Get type of Django form widget from within template
- [Django]-How do I refresh the values on an object in Django?
Source:stackexchange.com