Wagtail CMS: Registering Snippets (Blog Category) using Checkboxes

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

Coding For Everybody

Coding For Everybody

Күн бұрын

In this tutorial we'll be learning how to register another Wagtail Snippet, but instead of using an Orderable and a SnippetChooserPanell (like the previous lesson) we're going to use a ParentalManyToManyField and a form widget to create Checkboxes in the Wagtail Admin.
Tutorial: learnwagtail.com/tutorials/re...
Git Commit: github.com/CodingForEverybody...
Learn Wagtail from scratch with the official Wagtail for Beginners Course
learnwagtail.com/wagtail-for-...
Used in this video: Wagtail 2.4, Python 3.7, Django 2.1.5 #Wagtail #Django #Python

Пікірлер: 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 3 жыл бұрын
Great tutorial and amazing instructor :) I click like button before I watch the videos !!
@CodingForEverybody
@CodingForEverybody 3 жыл бұрын
Amazing! Thank you so much for the support!
@richardallen543
@richardallen543 3 жыл бұрын
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
@IllevensKO
@IllevensKO 4 жыл бұрын
Is there any way to use tag chooser panel style ? Can't find anything about it.
@Cosas1008
@Cosas1008 3 жыл бұрын
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()
@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 4 жыл бұрын
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)
@richardallen543
@richardallen543 3 жыл бұрын
@@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.
Wagtail CMS: How to Create a Custom Wagtail Menu System
38:22
Coding For Everybody
Рет қаралды 20 М.
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 170 МЛН
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 7 МЛН
Дарю Самокат Скейтеру !
00:42
Vlad Samokatchik
Рет қаралды 8 МЛН
How to use Orderables in Wagtail CMS
22:42
Coding For Everybody
Рет қаралды 14 М.
Wagtail CMS: Registering Snippets using Django Models
13:35
Coding For Everybody
Рет қаралды 10 М.
Wagtail CMS: Routable Page Categories And Years
19:01
Coding For Everybody
Рет қаралды 3,8 М.
Learn Zod In 30 Minutes
31:03
Web Dev Simplified
Рет қаралды 138 М.
Getting Started With Your First Home Page in Wagtail CMS
16:31
Coding For Everybody
Рет қаралды 65 М.
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 170 МЛН