Static no Django

Asked

Viewed 30 times

1

People, Wanted advice or help on the 'Static' in 'Django', my files that are in the 'Static" folder they are not loaded presenting the following errors below:

    System check identified no issues (0 silenced).
December 30, 2020 - 15:49:40
Django version 3.1.4, using settings 'core.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[30/Dec/2020 15:49:47] "GET / HTTP/1.1" 200 6889
[30/Dec/2020 15:49:47] "GET /static/js/plugins/plugins.js HTTP/1.1" 404 1689
[30/Dec/2020 15:49:47] "GET /static/js/bootstrap/popper.min.js HTTP/1.1" 404 1704
[30/Dec/2020 15:49:47] "GET /static/site.css HTTP/1.1" 404 1650
[30/Dec/2020 15:49:47] "GET /static/js/active.js HTTP/1.1" 404 1662
[30/Dec/2020 15:49:47] "GET /static/js/jquery/jquery-2.2.4.min.js HTTP/1.1" 404 1713
[30/Dec/2020 15:49:47] "GET /static/js/bootstrap/bootstrap.min.js HTTP/1.1" 404 1713
[30/Dec/2020 15:49:47] "GET /static/img/core-img/pizza.png HTTP/1.1" 404 1692
[30/Dec/2020 15:49:47] "GET /static/static/img/bg-img/foto_receita.png HTTP/1.1" 404 1728
[30/Dec/2020 15:49:47] "GET /static/img/core-img/logo.png HTTP/1.1" 404 1689
[30/Dec/2020 15:49:47] "GET /static/js/bootstrap/popper.min.js HTTP/1.1" 404 1704
[30/Dec/2020 15:49:47] "GET /static/js/bootstrap/bootstrap.min.js HTTP/1.1" 404 1713
[30/Dec/2020 15:49:47] "GET /static/js/plugins/plugins.js HTTP/1.1" 404 1689
[30/Dec/2020 15:49:47] "GET /static/js/active.js HTTP/1.1" 404 1662

In my folder Settings.py is as follows

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, '/static')
]

and my urls.py is so:

urlpatterns = [
    path('',include('receitas.urls')),
    path('admin/', admin.site.urls),
] #+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

Someone who’s been there that might shed some light ?

1 answer

0

After deploying the application, you need to execute the command:

python manage.py collectstatic

Thus the data of the Static folder will be copied in the proper places (configured in your settings.py) .

Follows the reference of collectstatic from Django.

Browser other questions tagged

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