Django and HTMX #15 - Click to Load pattern

preview_player
Показать описание
In this video, we'll demonstrate the Click to Load pattern using Django and HTMX - this pattern allows dynamic loading of new data from the server.

We'll look at how to hook up pagination to this workflow, that allows us to fetch the correct batch of data each time new data is loaded.

▶️ Full Playlist:

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
00:55 Setup
01:20 Creating Student model
02:25 Registering model with admin
03:33 Creating student list URL & view
05:21 Creating student-list template
07:26 Paginating student list view
09:20 Adding HTMX attributes to button
10:44 Adding django-htmx package
13:07 Adding page has_next check

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:

#django #htmx #python
Рекомендации по теме
Комментарии
Автор

Am loving your htmx Django tutorials.I believe I can now make my web applications in production more dynamic.Thanks man.

repotranstech
Автор

Another well designed and to the point tutorial. I'm loving these. A bonus would be to use class based views instead of function based .... hint hint :) Keep up the great work.

khunjohn
Автор

Excellent video. In addition, I suggest using HTMX loading states extension to control what's happening during the request itself. For example, you may want to display a spinner, or make the "load more" button invisible to prevent the user clicking twice.

darkbluewalther
Автор

You crushed it once again! excellent video.

DelioC
Автор

The best content at the best time as always, thanks

manofhat
Автор

Great video, as always! It worked well for me without installing django-htmx and obviously without doing the if request hx.htmx. It seems django can handle the request without installing it. Or a I missing something?

hernansaa
Автор

Do you maybe have a tutorial on how to load admin pages from includes sidebar to div with block content?

TomislavMiletic
Автор

Great series! Learnt a lot! Can you give advice according to implement if GET request from htmx in CBV. 11:32 Which method should I overwrite to be able to use two different templates in CBV? The first thing that came to mind to overwrite get_template_names(), but there is no access to request.

savroful
Автор

When using htmx, I pressed the recommend button, but sometimes it doesn't work normally.
At this time, there are times when you can press the recommend button again, but there are times when it is not.
In this case, what should I do to make the recommendation function I wanted work normally with one click?

myoji
Автор

Hey. I have a database with articles that have titles and contents. I have a page where I fetching titles of articles from DB in a list of links. Then I click on a link and in other template shows a content of a particular article. Is there a way to show content of article in the same page where the list of articles is? One side of the page for links and clicking on a link change content of article depending it’s title.

ВиталийМинич-яя
Автор

and what when i want use more request.htmx in one function?

grzegorzkalmus
Автор

Side note: it works like a charm with generic ListView too. You juste need to set paginate_by attribute, and override the get_template_names method to add the "if self.request.htmx" trick

darkbluewalther
Автор

Does this only work with a table or can you use a looped Div as well?

jenteotte
Автор

For some reason my table is being generated over and over for every entry in my database

kodeypatterson
Автор

Thnx for video. But I couldn't figure out how I can use 2 Load pattern in one template. Because of

if request.htmx:
return render(request, context)

Could you please guide me?

scknylmz
Автор

thank you for this best tutorial , can you please make a thumb up and thumb down or like and dislike, and comment post, its very important for as a beginner in django, ,, i will thankful to you

alialrubay