10π
β
I had the same problem but was resolved after loading crispy {% load crispy_forms_tags %} form at the top of my templates
{% extends 'base.html' %} {% block content %}
{% load crispy_forms_tags %}
<div class="container">
<div class="row">
<div class="col-md-8 card mb-4 mt-3 left top">
<div class="card-body">
<h1>{% block title %} {{ post.title }} {% endblock title %}</h1>
<p class=" text-muted">{{ post.author }} | {{ post.created_on }}</p>
<p class="card-text ">{{ post.content | safe }}</p>
</div>
</div>
{% block sidebar %} {% include 'sidebar.html' %} {% endblock sidebar %}
<div class="col-md-8 card mb-4 mt-3 ">
<div class="card-body">
<!-- comments -->
<h2>{{ comments.count }} comments</h2>
{% for comment in comments %}
<div class="comments" style="padding: 10px;">
<p class="font-weight-bold">
{{ comment.name }}
<span class=" text-muted font-weight-normal">
{{ comment.created_on }}
</span>
</p>
{{ comment.body | linebreaks }}
</div>
{% endfor %}
</div>
</div>
<div class="col-md-8 card mb-4 mt-3 ">
<div class="card-body">
{% if new_comment %}
<div class="alert alert-success" role="alert">
Your comment is awaiting moderation
</div>
{% else %}
<h3>Leave a comment</h3>
<form method="post" style="margin-top: 1.3em;">
{{ comment_form | crispy }}
{% csrf_token %}
<button type="submit" class="btn btn-primary btn-lg">Submit</button>
</form>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock content %}
π€Darkhorse
4π
please make shour that you include the {% load crispy_forms_tags %} inside the partials like :
{% extends 'posts/bases/base.html' %}
{% load crispy_forms_tags %}
{% block title%}
<title>Register</title>
{% endblock %}
{% block content%}
<h1>Register</h1>
<form action="" method="post">
{% csrf_token %}
{{ form|crispy }}
<button type="submit">Register</button>
</form>
{% endblock %}
if you load it in the base.html will not work
Django==3.1.4
django-crispy-forms==1.10.0
- Django ORM leaks connections when using ThreadPoolExecutor
- Difference between model fields(in django) and serializer fields(in django rest framework)
- What are some alternative for ModelChoiceField for large number of choices?
- Django-filter messing around with empty field
- Django ModelForm fails validation with no errors
2π
I have the same errorβ¦Youβare using (), like that:
(% load crispy_forms_tags %)
and not {}, like:
{% load crispy_forms_tags %}
- How to test postgresql credentials from bash?
- How to enable history in Django shell in python
- IntegrityError: null value in column "city_id " violates not-null constraint
- Difference between model fields(in django) and serializer fields(in django rest framework)
0π
A basic error (I often make) is that even though you load crispy_form_tags, you actually use crispy. The error Invalid filter: 'crispy_forms_tags'
may show up if you use {{form|crispy_forms_tags}}
instead of {{form|crispy}}
.
{% load crispy_forms_tags %}
{{ login_form | crispy_forms_tags }} /* <--- Invalid filter: 'crispy_forms_tags' */
{{ login_form | crispy }} /* <--- OK */
π€cottontail
- Django DatabaseError: relation "django_site"
- Using the django-auth-ldap LDAPSearch to search two OUs
- Nested URL Patterns in Django REST Framework
- How to check if a Django user is still logged in from the client side only?
- Can I run django tests (manage.py) from a different directory?
Source:stackexchange.com