I
I
iczczcz2018-06-07 20:47:20
Django
iczczcz, 2018-06-07 20:47:20

Is Django not working properly?

There is a pattern

{% extends "home/base.html" %}
{% load crispy_forms_tags %}


{% block content %}
    <div class="container">
        <div class="col-xs-8 col-xs-offset-2">
            <form action="." method="POST">
                {% csrf_token %}
                {{ form|crispy }}
                <br>
                <input type='submit' class='btn btn-default' value='Update'>
            </form>
        </div>
    </div>
{% endblock %}

For some reason, when loading in the browser console, I get GET 127.0.0.1:8000/posts/static/js/jquery-3.3.1.min.js 404 (Not Found) and many more such errors (with bootstrap, etc.)
At the same time, this template works absolutely fine
{% extends "home/base.html" %}
{% load crispy_forms_tags %}


{% block content %}
<div class="container">
    <h2>{{ title }} page</h2>
    <form method='POST' action='.'>
        {% csrf_token %}
        {{ form|crispy }}
        <input type='submit' class='btn btn-success'>
    </form>
</div>

<style>
    .asteriskField {
        display: none;
    }
</style>

{% endblock content %}

In base.html everything is connected normally
What's the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Web Dentist, 2018-06-07
@kgb_zor

Set up the static files correctly.

STATIC_URL = '/static/' 
или
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'posts/static'),
)

7
776166, 2018-06-08
@776166

You need to connect statics only through{% static "[путь до файла]" %}
Judging by your comments in the discussion, your project is either poorly planned in terms of statics, or you connect it incorrectly. Relative paths with ../ should not be used at all.
Most likely the correct path should be: /static/posts/js/jquery-3.3.1.min.js yes?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question