0

I've deployed my django application in production environment. Application's functionality is OK but the static files (css and image) were not rendered.

I've set the following in my settings.py, prior running collectstatic:

DEBUG = False
TEMPLATE_DEBUG = False

STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT = 'E:/django/project/app/static/'
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    'E:/django/project/app/staticfiles/',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.static',
)

TEMPLATE_DIRS = (
    'E:/django/project/app/templates',
)

INSTALLED_APPS = (
   'django.contrib.staticfiles',
   'project.app',
)

Under my app directory (i.e. E:/django/project/app/), I've created both static and staticfiles directories, and placed the css and the image used by the app (though I am not sure if this is necessary because I think this is quite redundant for this is done by the collectstatic).

I followed django's deployment instruction here. But again, my concern is the CSS and the image are not rendered. What should I do/modify to address this?

Your ideas are greatly appreciated. Thanks in advance!

jaysonpryde
  • 2,733
  • 11
  • 44
  • 61
  • What server are you running? – jlmcdonald Aug 20 '14 at 03:11
  • I am just using django's default/built-in server. Though this is in production, this is for small scale usage only. – jaysonpryde Aug 20 '14 at 03:34
  • 2
    That won't work the way you're expecting in a production environment. the built-in server runs all requests through your Django app's main controller, but the static files need to be served on their own through direct requests (basically, outside of the Django framework) or, as it states here: https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-during-development; you could set up URL patterns to have Django serve static files. Best way, though, is to configure a regular web server so that /static/ points to your static directory. – jlmcdonald Aug 20 '14 at 03:39

1 Answers1

0

Setting DEBUG=False will cause u problem in loading static files in development environment. Always set DEBUG=True in development environment.

Dylan CCC
  • 5
  • 5