0

I have the following directory structure in my project:

enter image description here

I'm trying to serve the static files in my environment, but I always getting the 404 error.

This is my settings.py configuration:

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

I also put this in my urls.py:

URLS:

from django.contrib.staticfiles.urls import staticfiles_urlpatterns  
urlpatterns += staticfiles_urlpatterns()

And this is my view:

{% load static %}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="../assets/images/favicon.png">
    <title>Nossas Finanças</title>
    <!-- Bootstrap Core CSS -->
    <link href="{% static 'plugins/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">

I've follow a lot of tutorials but I don't know what i'm doing wrong. I know by this question (Django Static Files Development) that the static files are served in two different way when is in Dev and in production.

Someone can help me?

Vitor Villar
  • 1,855
  • 18
  • 35

2 Answers2

0

Try this

os.path.join(BASE_DIR, "finances", "static")
itzMEonTV
  • 19,851
  • 4
  • 39
  • 49
0

For other people facing this problem and using Windows, keep in mind that you may need to restart the development server (the ".manage runserver" command) after having added new static files.