Best template

This commit is contained in:
Andros Fenollosa 2021-11-12 20:54:20 +01:00
parent c8fbf9fb4a
commit ae59910bb7
5 changed files with 23 additions and 13 deletions

View File

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<title>htmx demo</title>
<link rel="icon" type="image/png" href="favicon.png">
<link rel="icon" type="image/png" href="{% static "img/favicon.png" %}">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
<meta name="author" content="Andros Fenollosa">
<meta name="generator" content="Django">
@ -17,7 +17,7 @@
<script defer src="{% static "js/htmx.min.js" %}"></script>
</head>
<body>
<div class="container">
<div class="container" hx-ws="connect:ws:{{ DOMAIN }}/ws/pages/{{ room_random }}/">
<header>
<nav>
<ul>
@ -30,7 +30,7 @@
</ul>
</nav>
</header>
<main hx-ws="connect:ws:{{ DOMAIN }}/ws/pages/{{ room_random }}/" id="page"></main>
<main id="main"></main>
</div>
</body>
</html>

View File

@ -1,3 +1,3 @@
<main id="page">
<main id="main">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corporis dignissimos dolor inventore laudantium libero optio quo reprehenderit repudiandae sapiente similique. Delectus dolorum enim fuga fugiat ipsam nam recusandae sequi sint.
</main>

View File

@ -1,9 +1,20 @@
<main id="page">
<main id="main">
{% for talk in talks %}
<a href="#">
<article>
<header>{{ talk.title }}</header>
<p></p>
<header>
<div class="grid">
<p>
<img width="200" src="{{ talk.image.url }}">
</p>
<h2>{{ talk.title }}</h2>
</div>
</header>
<p>
{{ talk.content|truncatechars:100 }}
</p>
<footer>Author {{ talk.author.full_name }} - {{ talk.category.name }}</footer>
</article>
</a>
{% endfor %}
</main>

View File

@ -13,6 +13,7 @@ def index(request):
"DOMAIN": settings.DOMAIN,
})
def page_talks():
return render_to_string("pages/talks.html", {
"talks": Talk.objects.order_by("title")[:5]

View File

@ -19,9 +19,7 @@ def run():
category=Category.objects.order_by("?")[0],
author=Profile.objects.order_by("?")[0],
is_draft=False,
content="<p>"
+ "</p><p>".join(fake.paragraph(nb_sentences=randint(5, 10)))
+ "</p>",
content=fake.paragraph(nb_sentences=randint(20, 100)),
)
my_talk.save()