I want to run always in debug=false in django. However, it works only when i turned to debug to true. Otherwise not. In setting.py
DEBUG = False
also, in setting.py
STATIC_URL = '/static/'
STATIC_ROOT = '/static/'
MEDIA_URL = '/media/'
if DEBUG:
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
else:
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
In main urls.py
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('mysite.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
I have directory of media, static, staticfiles in the directory where manage py is located.
If i put code exactly in apache will my code works. P.S In development also i want to fix debug as false always.