Receiving the 404 error in getting of static django files
<p>Please help to understand what I do wrong.</p>

<p>I have in my settings.py :</p>

<pre><code>PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATIC_URL = os.path.join(PROJECT_ROOT, 'static').replace('\\','')+'/'
</code></pre>

<p>And in index.html :</p>

<pre><code>{% load static %}
&lt;link rel="stylesheet" type="text/css" href="{% static "/css/table.css" %}"&gt;
</code></pre>

<p>But I still have the error 404 :</p>

<pre><code>"GET /var/cardsite/cardsite/static/css/table.css HTTP/1.1" 404 1696
</code></pre>

<p>I have this file :</p>

<pre><code>ls -la /var/cardsite/cardsite/static/css/table.css
-rw-r--r-- 1 root root 77 Sep 25 16:15 /var/cardsite/cardsite/static/css/table.css
</code></pre>

<p>So what is going on?</p>

<p>P.S. My project stored on "/var/cardsite" and I want to make static folder on each application, like in example is default application "cardsite"</p>

<p>thanks</p>

<p>Read this <a href="https://docs.djangoproject.com/en/1.10/howto/static-files/" rel="nofollow">Django_Docs</a><br>
You must also have a <code>STATIC_ROOT</code> option set before you can use the static files, heres some help
add this to your code:</p>

<pre><code>STATIC_URL = os.path.join(PROJECT_ROOT, 'static').replace('\\','')+'/'

# Here you can add all the directories from where you want to use your js, css etc
STATICFILES_DIRS = [
  # This can be same as the static url
  os.path.join(PROJECT_ROOT, "static"),

  # also any other dir you wanna use
  "/any/other/static/path/you/wanna/use",
]

# This is the static root dir from where django uses the files from.
STATIC_ROOT = os.path.join(PROJECT_ROOT, "static_root")
</code></pre>

<p>you will also need to specify it in the <code>urls.py</code> file, just add the following code to the <code>urls.py</code> file:</p>

<pre><code>from django.conf import settings
from django.conf.urls.static import static

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
</code></pre>

<p>after you add this, run the command:</p>

<pre><code>python manage.py collectstatic
</code></pre>

<p>This will copy all the statics you need to the static root dir.</p>

python html css django static