Hello guys,
I need someone to help me fix an issue. By the way, my web application in my local computer displays well all static files (css, JavaScript and images) but in production, only images are not displayed in Pythonanywhere. Also, in addition to the content of the local static directory, I have noticed two sub-directories named 'admin' and 'rest_framework' that have been added to the aforementioned directory in production. I am using MDB templates and static files.
This is what I put in my settings.py files
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
I mentioned the {% load static %} at the beginning of the template that holds the images, css and JavaScript static files but all the static files works in production except for images:
This is a code snippets of the template:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Material Design Bootstrap</title>
<!-- Font Awesome -->
<link rel="stylesheet" href="{% static 'https://use.fontawesome.com/releases/v5.11.2/css/all.css' %}">
<!-- Bootstrap core CSS -->
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="{% static 'css/mdb.min.css' %}" rel="stylesheet">
<!-- Your custom styles (optional) -->
<link href="{% static 'css/style.min.css' %}" rel="stylesheet">
For images, the code example bellow works well in my local computer when loading static files: <img src="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/12.jpg" class="card-img-top" alt="">
I really need help for this issue. Can someone help me please ?
[edit by admin: formatting]