Wagtail CMS: Registering Snippets (Blog Category) using Checkboxes

  Рет қаралды 7,298

Coding For Everybody

Coding For Everybody

Күн бұрын

Пікірлер: 12
@hamednajand8327
@hamednajand8327 4 жыл бұрын
You're awesome! the way you teach is the one way that I'm exciting to follow and in fact, I don't sleep during the video :))
@CodingForEverybody
@CodingForEverybody 4 жыл бұрын
(▀Ĺ̯▀ ̿) Thank you!! :D
@nooralqoj4575
@nooralqoj4575 4 жыл бұрын
Great tutorial and amazing instructor :) I click like button before I watch the videos !!
@CodingForEverybody
@CodingForEverybody 4 жыл бұрын
Amazing! Thank you so much for the support!
@IllevensKO
@IllevensKO 4 жыл бұрын
Is there any way to use tag chooser panel style ? Can't find anything about it.
@boryskuczkowski
@boryskuczkowski 5 жыл бұрын
@15:45 Have you, eventually, implemented the filter?
@CodingForEverybody
@CodingForEverybody 5 жыл бұрын
Nope I don't believe so. But it'd be as easy as BlogDetailPage.objects.live().public().filter(categories__slug__in=[request.GET.get('category')]), or something along these lines. (Note: that's untested, so you may need to adjust it)
@DouglasMcKey
@DouglasMcKey 5 жыл бұрын
I applied the filter my side, I used this: # Get all the blog posts. posts = BlogDetailPage.objects.live().public() # Identify recent posts and send to template: context["recent_posts"] = posts[:5] # Check if there is a category slug in the URL to filter the blog posts by. category_slug = request.GET.get("category", None) context["blog_posts"] = posts # By default - set to all posts if category_slug: # Must have a count > 0 in order to display something if posts.filter(categories__slug__contains=category_slug).count() > 0: context["blog_posts"] = posts.filter(categories__slug__contains=category_slug) else: context["blog_posts"] = posts # Seems like repetition but it caters for the 0 count on a blog_slug. ** I used the context["recent_posts"] to create a latest 5 posts navigation on the right of my content. Reverse ordered in template. ** I used the context["blog_posts"] to actually filter the blog list view when certain categories were clicked. (Only displayed categories with more than 0 posts associated to them)
@goneforawander_com
@goneforawander_com 4 жыл бұрын
@@DouglasMcKey using categories__slug__contains=category_slug doesn't work if the name of the category forms part of the name of other categories. It'll pick up all those categories instead of just the one you want. I tried this with having Education, Early Education, Environmental Education. When I went with ?=Education I got all 3 categories. Just categories__slug=category_slug works fine though.
@goneforawander_com
@goneforawander_com 4 жыл бұрын
Great tutorial, especially working out the filtering by category. Immensely useful :) Probably wouldn't be trusting content editors to make slugs though 😂 I went with the autoslug field from django extensions: from django_extensions.db.fields import AutoSlugField ... slug = AutoSlugField( populate_from=['name'], verbose_name='slug', allow_unicode=True, max_length=200, ) then drop slug from the panel
@Cosas1008
@Cosas1008 4 жыл бұрын
filter inspired by Kalob if request.GET.get('category'): context["posts"] = BlogDetailPage.objects.live().public().filter(categories__slug__in=[request.GET.get('category')]) else: context["posts"] = BlogDetailPage.objects.live().public()
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
How I make beautiful GRAPHS and PLOTS using LaTeX
28:46
Dr. Trefor Bazett
Рет қаралды 488 М.
How to use Orderables in Wagtail CMS
22:42
Coding For Everybody
Рет қаралды 15 М.
Simon Sinek's Advice Will Leave You SPEECHLESS 2.0 (MUST WATCH)
20:43
Alpha Leaders
Рет қаралды 2,7 МЛН
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 225 М.
How To Slugify Category Page URLs - Django Blog #14
7:53
Codemy.com
Рет қаралды 34 М.