0

I'm a beginner at Python, my settings.py:

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'theme', 'static'),
]

If I turn DEBUG to False,the staticfiles and mediafiles don't work, when i run devserver in insecure mode:

python manage.py runserver --insecure

The staticfiles works,but mediafiles(avatars) still doens't work.

my app installed way:

pip install misago

start path: /home/project/

Can someone help me? thanks.

datacamp
  • 11
  • 4
  • Misago 0.5 will not work with Django 1.7 and above. Just sayin – Rahul Jul 06 '17 at 07:36
  • `set DEBUG to False`, django in deployment mode and use `STATIC_ROOT`, see [static-files-deployment](https://docs.djangoproject.com/en/1.11/howto/static-files/deployment/#serving-the-site-and-your-static-files-from-the-same-server) – Cheney Jul 06 '17 at 07:44
  • 1
    Possible duplicate of [Python Django media url not working after setting DEBUG = True](https://stackoverflow.com/questions/28478159/python-django-media-url-not-working-after-setting-debug-true) – Steffen Jul 06 '17 at 07:46

1 Answers1

0

Django with debug false, does not manage the statics and media files.

You need to:

  1. Add "statics root" and "media root" to your django settings.py file
  2. Use NGINX to manage statics file (see more info about deployment on django documentation)
  3. use "collect static" command to collect the static/media file
Mattia
  • 961
  • 13
  • 25