I have deployed a django(1.7) project in pythonanywhere and its link is- http://drchitradhawle.pythonanywhere.com/ I guess there is the problem with static file linking and bootstrap.Plz anybody help me to sort out the problem also tell me whole procedure to link any static file and bootstrap in a django project.
My project structure is -
home
-DrChitraDhawle
-website
-webpage
-static
-css
-images
-templates
-website
-settings.py
settings.py file is -
STATIC_ROOT = "/home/DrChitraDhawle/website/webpage/static"
STATIC_URL = '/static/'
STATICFILES_DIR = (
('assets', '/home/DrChitraDhawle/website/webpage'),
)
#
#STATICFILES_DIR = [os.path.join(BASE_DIR, '')]
Link of static file set in web tab is -
And i have used it in my program as -
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'webpage/bootstrap.min.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'webpage/style.css' %}" />
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dr.Chitra Webpage</title>
.
.
.
error log on python anywhere is -
2015-03-08 16:09:52,766 :django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
2015-03-08 16:09:53,926 :Traceback (most recent call last):
2015-03-08 16:09:53,926 : File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-03-08 16:09:53,926 : self.error_log_file.logger.exception("Error running WSGI application")
2015-03-08 16:09:53,926 : File "/usr/lib/python2.7/logging/__init__.py", line 1185, in exception
2015-03-08 16:09:53,926 : self.error(msg, *args, **kwargs)
2015-03-08 16:09:53,927 : File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
2015-03-08 16:09:53,927 : self._log(ERROR, msg, args, **kwargs)
2015-03-08 16:09:53,927 : File "/usr/lib/python2.7/logging/__init__.py", line 1270, in _log
2015-03-08 16:09:53,928 : record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2015-03-08 16:09:53,928 : File "/usr/lib/python2.7/logging/__init__.py", line 1244, in makeRecord
2015-03-08 16:09:53,928 : rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2015-03-08 16:09:53,928 : File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2015-03-08 16:09:53,928 : self.threadName = threading.current_thread().name
2015-03-08 16:09:53,928 : File "/usr/lib/python2.7/threading.py", line 1160, in currentThread
2015-03-08 16:09:53,929 : return _active[_get_ident()]
2015-03-08 16:09:53,929 : File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-03-08 16:09:53,929 : app_iterator = self.app(environ, start_response)
2015-03-08 16:09:53,929 : File "/bin/user_wsgi_wrapper.py", line 136, in import_error_application
2015-03-08 16:09:53,929 : raise e
2015-03-08 16:09:53,929 :django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
Access log -
78.12.109.13 - - [09/Mar/2015:10:55:39 +0000] "GET /static/webpage/images/chitraMam.jpg HTTP/1.1" 404 1165 "http://drchitradhawle.pythonanywhere.com/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36" "78.12.109.13"
78.12.109.13 - - [09/Mar/2015:10:55:40 +0000] "GET /favicon.ico HTTP/1.1" 404 1150 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36" "78.12.109.13"
78.12.109.13 - - [09/Mar/2015:10:55:43 +0000] "GET /static/webpage/bootstrap.min.css HTTP/1.1" 404 1164 "http://drchitradhawle.pythonanywhere.com/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36" "78.12.109.13"
78.12.109.13 - - [09/Mar/2015:10:55:43 +0000] "GET /static/webpage/style.css HTTP/1.1" 404 1154 "http://drchitradhawle.pythonanywhere.com/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36" "78.12.109.13"
78.12.109.13 - - [09/Mar/2015:10:55:56 +0000] "GET /static HTTP/1.1" 404 1148 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36" "78.12.109.13"
78.12.109.13 - - [09/Mar/2015:10:55:58 +0000] "GET /static/ HTTP/1.1" 404 1149 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36" "78.12.109.13"
78.12.109.13 - - [09/Mar/2015:10:56:03 +0000] "GET /static/webpage/ HTTP/1.1" 404 1151 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36" "78.12.109.13"
14.139.240.226 - - [09/Mar/2015:11:04:16 +0000] "GET /webpage/research/ HTTP/1.1" 200 1615 "http://drchitradhawle.pythonanywhere.com/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0" "14.139.240.226"
14.139.240.226 - - [09/Mar/2015:11:04:17 +0000] "GET /static/webpage/bootstrap.min.css HTTP/1.1" 404 1164 "http://drchitradhawle.pythonanywhere.com/webpage/research/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0" "14.139.240.226"
14.139.240.226 - - [09/Mar/2015:11:04:17 +0000] "GET /static/webpage/style.css HTTP/1.1" 404 1154 "http://drchitradhawle.pythonanywhere.com/webpage/research/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0" "14.139.240.226"
14.139.240.226 - - [09/Mar/2015:11:04:18 +0000] "GET /static/webpage/style.css HTTP/1.1" 404 1154 "http://drchitradhawle.pythonanywhere.com/webpage/research/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0" "14.139.240.226"
14.139.240.226 - - [09/Mar/2015:11:04:18 +0000] "GET /static/webpage/bootstrap.min.css HTTP/1.1" 404 1164 "http://drchitradhawle.pythonanywhere.com/webpage/research/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0" "14.139.240.226"
three things I would look into.
your error log says: "The SECRET_KEY setting must not be empty" -- you should investigate whether this is still an issue. Look for
SECRET_KEY
in settings.py.in settings.py, the only two settings you really need are
STATIC_URL
andSTATIC_ROOT
.STATIC_ROOT
should be a folder that is separate from your app folders, so I would put it somewhere like /home/DrChitraDhawle/website/. I recommend deleting theSTATICFILES_DIR
setting.Then you will need to run the
collectstatic
command, which tells django to copy all your static files from each app into yourSTATIC_ROOT
folder:That will copy your static files from the webpage/static folder into the website/static folder, and you will need to re-run it whenever you add or remove static files.
There's more information on the PythonAnywhere wiki, here: https://www.pythonanywhere.com/wiki/DjangoStaticFiles and in the django documentation, here: https://docs.djangoproject.com/en/1.7/howto/static-files/
The reason why your static files don't work is because your static files is set to
home/DrChitraDhawle/website/webpage/static
in the webtab screenshot. It should be/home/DrChitraDhawle/website/webpage/static
The error logs are old (ie. you probably have not generated any new errors since you've last fixed the old ones)