wagtail

wagtail AbstractImage, ParentalManyToManyField and ClusterableModel

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-07 17:25:40
问题 Using wagtail 2.1, django 2.0.3, python 3.6.4 I have the following (simplified) custom image model, linked to PhotoType and PhotoPlate via m2m relationships: from wagtail.images.models import AbstractImage from modelcluster.fields import ParentalManyToManyField from modelcluster.models import ClusterableModel class PhotoType(models.Model): title = models.CharField(verbose_name='Title', max_length=255, blank=False, null=False, default=None) class PhotoPlate(models.Model): plate= models

New root page in wagtail

心不动则不痛 提交于 2021-02-07 09:51:47
问题 I want to change the Root page in Wagtail. I have deleted the default home page Created another page assigned "home" as slug. Created a template my_page_name_home.html But I am getting 404 all the time when I try http://localhost:8000/. Do I have to change the urls.py patterns? I am doing this because of Wagtailtrans add-on. In order to work i have to redirect away from the homepage to my new page ot type TranslatableSiteRootPage 回答1: You need to go to Settings -> Sites in the Wagtail admin,

Wagtail SnippetChooserBlock in Streamfield

主宰稳场 提交于 2021-02-07 08:58:33
问题 I am having some trouble getting the values from a snippet, that I have included into a streamfield using a Snippet Chooser Block. BioSnippet: @register_snippet class BioSnippet(models.Model): name = models.CharField(max_length=200, null=True) job_title = models.CharField(max_length=200, null=True, blank=True) bio = RichTextField(blank=True) image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', verbose_name='Bio Image' ) contact

Wagtail SnippetChooserBlock in Streamfield

[亡魂溺海] 提交于 2021-02-07 08:57:16
问题 I am having some trouble getting the values from a snippet, that I have included into a streamfield using a Snippet Chooser Block. BioSnippet: @register_snippet class BioSnippet(models.Model): name = models.CharField(max_length=200, null=True) job_title = models.CharField(max_length=200, null=True, blank=True) bio = RichTextField(blank=True) image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', verbose_name='Bio Image' ) contact

Limit ImageChooserPanel to children of current Page?

只愿长相守 提交于 2021-01-29 22:00:53
问题 Our site has users who create PropertyPages, and they upload images about each Property. We want these images to not be shared with other Property or other pages, nor other users' content. But the ImageChooserPanel has access to ALL images uploaded to the site, and newly uploaded images are available to any other user of that Chooser. I am looking for a way to associate images strongly with the individual page; we may only need the upload, not chose from existing images. Is there a way to do

Wagtail modeltranslation language switcher doesn't work on /search page

落爺英雄遲暮 提交于 2021-01-29 18:22:59
问题 I have added search url to i18n_patterns , but the language switcher doesn't work on that page. urls.py: urlpatterns += i18n_patterns( path("search/", search_views.search, name="search"), path("", include(wagtail_urls)), ) language switcher: {% get_available_languages_wmt as languages %} <div class="nav-item dropdown float-right"> <p class="nav-link dropdown-toggle m-auto" data-toggle="dropdown" role="button" aria-expanded="false"> {{ request.LANGUAGE_CODE|upper }}</p> <div class="dropdown

What is the difference between ChildPage.objects.child_of(self) and ParentPage.get_children()?

六月ゝ 毕业季﹏ 提交于 2021-01-29 15:21:14
问题 I think that ChildPage.objects.child_of(self) and ParentPage.get_children() produce same result because subpage_types of ParentPage is just one ['ChildPage'] . But when I try to filter the result of ParentPage.get_children() there is an error. def get_context(self, request, *args, **kwargs): context = super().get_context(request, *args, **kwargs) child = self.get_children().live().public() # <- don't works child = ChildPage.objects.child_of(self).live().public() # <- works if request.GET.get(

Wagtail: how to set calculated fields (@property) title in admin

不羁岁月 提交于 2021-01-29 14:38:58
问题 I use ModelAdmin module for my models in Wagtail. I have @property fields in models, where I return some annotated data and display it Index and Inspect Views in Admin. But Wagtail set title of such fields as field name in model. In regular field I use verbose_name to set nice title, how can I change titles for property field? 回答1: You have to create your own ReadOnlyPanel as it is not possible with Wagtail. mypanel.py from django.forms.utils import pretty_name from django.utils.html import

Bulk uploading and creating pages with images in wagtail (migration)

感情迁移 提交于 2021-01-29 13:50:47
问题 I'm creating a website with wagtail to replace someone's existing weebly site. It would take hours to re-create each of the hundreds of page instances and upload each image for each of those pages. I already have the page models I need, and my site looks a lot like the getting started tutorial from the wagtail docs. I'm wondering how I might be able to script migrating this content. When searching for answers I'm finding more information about programmatically creating models, rather than

Wagtail: Filter Pages by a ForeignKey

早过忘川 提交于 2021-01-29 09:20:58
问题 Using Wagtail I want to get a QuerySet of Page s whose specific subclass have a certain ForeignKey to a Snippet . from django.db import models from wagtail.core.models import Page from wagtail.snippets.models import register_snippet @register_snippet class Organization(models.Model): name = models.CharField(max_length=255, blank=False) class ArticlePage(Page): organization = models.ForeignKey( 'Organization', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' ) So, how would I