0
Well, it was all right until a certain moment. Then I don’t know what happened, or if I put something wrong and nothing else is working. Django stopped reading the static files.
When I try to enter any page of my application the following error appears:
I have checked my code several times but found no error, the part that are the Static is this:
{% load static %}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'css/select2.min.css' %}">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="{% static 'js/jquery-3.4.1.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/select2.min.js' %}"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).on('click', '.confirm-delete', function() {
$('#confirmDeleteModal').attr('caller-id', $(this).attr('id'));
});
$(document).on('click', '#confirmDeleteButtonModal', function() {
var caller = $('#confirmDeleteButtonModal').closest('.modal').attr('caller-id');
window.location = $('#'.concat(caller)).attr('href');
});
$(function() {
$('#id_end_date').datepicker(
{
dateFormat: "dd/mm/yy",
dayNamesMin: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"],
monthNames: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
});
});
$(document).ready(function() {
$('#id_category').select2();
});
</script>
And in Settings.py:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'staticfiles'),
]
What worries me most is that the admin page (http://127.0.0.1:8000/admin), also not working. The following error appears:
My directories:
If I can help end this mistake, I’d really appreciate it!
Which version of Django are you using ?
– Otávio Reis Perkles
version = (3, 0, 4, 'final', 0)
– Franco Motta
Tried {%load staticfiles %} above {%load Static %} ?
– Otávio Reis Perkles
Yes! it does not accept staticfiles'
– Franco Motta
Using {% load staticfiles %} instead of {% load Static %}, didn’t work? Rename your folder with Static files, from staticfiles to Static. Another possibility, you removed the 'DEFAULT_APPS' entry 'Django.contrib.staticfiles' from the DEFAULT_APPS options in Settings.py',?
– Ernesto Casanova
No, it’s an error ('staticfiles' is not a Registered tag library) and tells you to use only 'Static'. I already changed the name of the folder to test it before and it didn’t work either. Yes, that option is still there. The only thing is that in mine is DJANG_APPS. I switched to DEFAULT only for conscience disenchantment, but it didn’t change anything... The funny thing is that it was working, I don’t know if I did something that out of nowhere is giving this error.
– Franco Motta
And it’s very strange that Admin isn’t working either. It’s as if it stops reading the statics files...
– Franco Motta
This is occurring either in production or locally with
runserver
?– Sidon
Local, on the same runserver
– Franco Motta