Reputation: 445
I have a Django 1.11 app that I want to deploy on a CentOS 7 server, which I access via a terminal from my Ubuntu 16.10 guest on Windows 10 host through Virtualbox 5.1.18.
After reconstructing my working environment on CentOS and cloning the repository I decided to run a development server to check if all python packages have been successfully installed and loaded (I went for python manage.py runserver 0:0:0:8000 to be able to connect to the app from Ubuntu guest).
My problem is the following - although the app works fine, for some reason the app on CentOS does not "see" the .css files, which results in styles not being loaded. I double-checked that the files are there, and in settings.py I have:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
So the relative paths have not changed and yet the styles are not loaded on CentOS while they work perfectly well on Ubuntu.
Anyone knows how to fix the problem and what caused it?
EDIT:
Since there was no helpful answer or comment I now deployed the application using uwsgi and nginx and the problem obviously persists. Will I get a helpful answer now please?
UPDATE:
Thanks to Haroldo_OK I realized that probably what's at fault is the way the frontend was developed:
<head>
<base href="http://127.0.0.1:8000" />
<link rel="stylesheet" href="{% static 'css/cover.css' %}">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Kontakt</title>
<!-- Bootstrap core CSS -->
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="cover.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="../../assets/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
Anyone knows how should I change it and what should I download and where to put it for a fix? I really have no clue about frontend...
Upvotes: 1
Views: 180
Reputation: 5854
the path to static URL should be of your hosting platform CentOS 7 server
path of static URL on server is different from local
correct your static URL path
Upvotes: 1