Exclude main content from spaceless

This commit is contained in:
Gabriel Augendre 2021-01-05 19:04:12 +01:00
parent bb1f2a7838
commit 06205dbaea
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
2 changed files with 4 additions and 9 deletions

View file

@ -1,7 +1,7 @@
{% load static compress %}
{% spaceless %}
<!DOCTYPE html>
<html lang="en">
{% spaceless %}
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
@ -35,12 +35,14 @@
<p>{{ blog_description }}</p>
{% include "articles/snippets/navigation.html" %}
</header>
{% endspaceless %}
<main>
{% block content %}
{% endblock %}
</main>
{% spaceless %}
<footer>
<hr>
<p>
@ -64,5 +66,5 @@
{% endcompress %}
</body>
{% endspaceless %}
</html>
{% endspaceless %}

View file

@ -50,16 +50,9 @@ def _assert_article_is_rendered(item: Article, res):
content = res.content.decode("utf-8")
assert item.title in content
html = item.get_formatted_content
html = get_spaceless_html(html)
assert html in content
def get_spaceless_html(html):
context = Context({})
html = Template("{% spaceless %}" + html + "{% endspaceless %}").render(context)
return html
@pytest.mark.django_db
def test_anonymous_cant_access_draft_detail(
client: Client, unpublished_article: Article