Django is not reading the Static statistic files

Asked

Viewed 219 times

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: inserir a descrição da imagem aqui

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:

inserir a descrição da imagem aqui

My directories:

inserir a descrição da imagem aqui

If I can help end this mistake, I’d really appreciate it!

  • Which version of Django are you using ?

  • version = (3, 0, 4, 'final', 0)

  • Tried {%load staticfiles %} above {%load Static %} ?

  • Yes! it does not accept staticfiles'

  • 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',?

  • 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.

  • And it’s very strange that Admin isn’t working either. It’s as if it stops reading the statics files...

  • This is occurring either in production or locally with runserver?

  • Local, on the same runserver

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.