wagtail

Creating a TagsBlock for StreamField

允我心安 提交于 2020-04-18 05:48:05
问题 I'm trying to create a struck block, which has a tags field so the user could choose the tags he wants to filter from. I created the tags field using wagtail.admin.widgets import AdminTagWidget . class TagsBlock(FieldBlock): field = forms.CharField( widget=AdminTagWidget ) class RelatedArticlesBlock(StructBlock): title = CharBlock(required=False) filter_tags = TagsBlock() no_of_items = IntegerBlock() It works as expected for selecting tags. But when I save it gives validation errors because

How can I return a queryset for a fk or m2m field in wagtail admin create form?

醉酒当歌 提交于 2020-03-26 03:06:05
问题 My question holds for any wagtail panel that returns select options from a foreignkey or M2M relationship, like a PageChooserPanel or SnippetChooserPanel. How can I filter the list of options server-side, for the user to only see the information he has access to? I have a Plan model. When creating a new plan, I would like request.user to only see the list of companies he is affiliated to. from modelcluster.models import ClusterableModel from wagtailautocomplete.edit_handlers import

Having a 404 for each site in a Wagtail multisite setup

泄露秘密 提交于 2020-03-01 01:52:26
问题 I'm trying to get two different Wagtail sites to have their own 404 pages, but there does not appear to be a way to specify which page to use as 404 page in a "site" config in the wagtail "settings" => "sites" section, and I can't seem to get the correct 404 to be loaded when I put them into the app directories involved: codebase/ ./__init__.py ./manage.py ./apps/ ./settings.py ./urls.py ... ./django-app-1/ ./django-app-2/ ./templates/ ./404.html ./mainsite/ ./migrations/ ./static/ .

Implementing one to many between an article and page models in Wagtail

丶灬走出姿态 提交于 2020-02-24 19:12:45
问题 I'm trying to setup a Wagtail site with an article to pages structure but I'm struggling. A review article for example may have an introduction page, a benchmark page and a conclusion page. I want to work out how to allow this relationship in wagtail and have it so that editors can add multiple pages to the same article on the same page. I can imagine the pages interface looking a bit like how you have content, promote and settings on pages but with the ability to add, rename and reorder

Implementing one to many between an article and page models in Wagtail

天大地大妈咪最大 提交于 2020-02-24 19:10:39
问题 I'm trying to setup a Wagtail site with an article to pages structure but I'm struggling. A review article for example may have an introduction page, a benchmark page and a conclusion page. I want to work out how to allow this relationship in wagtail and have it so that editors can add multiple pages to the same article on the same page. I can imagine the pages interface looking a bit like how you have content, promote and settings on pages but with the ability to add, rename and reorder

Save the dynamically populated value on dropdown

徘徊边缘 提交于 2020-01-25 03:49:53
问题 I'm using wagtail CMS for Django, I want to add a dynamically populated value for a dropdown and save it on the Page model, this is my code: class MyPage(Page): domain = CharField(max_length=10, choices=MY_CHOICES) subdomain = CharField(max_length=10, choices=[('', '------')] I've got some frontend logic to populate dynamically the options for subdomain, but after I hit save I got: The page could not be created due to validation errors And in the subdomain field: Select a valid choice. [my

Wagtail: How to verify if a user can access a page in the template

本秂侑毒 提交于 2020-01-25 00:13:05
问题 I am creating a personal website using Django with Wagtail , in which users belonging to different groups can access certain pages. For example, the family group can see my holiday photos, while the co-workers group can see some internal documents. Setting up permissions access permission is very straightforward through the admin. However, I would like to show a lock next to the link to forbidden pages. This will make it very clear to the user which links can be followed and which ones can't.

Django storages S3 - Store existing file

谁说胖子不能爱 提交于 2020-01-24 14:12:48
问题 I have django 1.11 with latest django-storages, setup with S3 backend. I am trying to programatically instantiate an ImageFile, using the AWS image link as a starting point. I cannot figure out how to do this looking at the source / documentation. I assume I need to create a file, and give it the path derived from the url without the domain, but I can't find exactly how. The final aim of this is to programatically create wagtail Image objects, that point to S3 images (So pass the new

Uploading Wagtail images from outside of wagtail

余生长醉 提交于 2020-01-14 18:46:59
问题 In a Django model that cannot subclass Page , I want to convert an existing ImageField to use Wagtail images. I have redefined the field as: avatar = models.ForeignKey( 'wagtailimages.Image', null=True, on_delete=models.SET_NULL, related_name='+' ) The user needs to be able to upload an image to their profile view. In forms.py for the Django view, I have: avatar = forms.ImageField( label='Your Photo', required=False, error_messages={'invalid': "Image files only"}, widget=forms.FileInput())

Uploading Wagtail images from outside of wagtail

℡╲_俬逩灬. 提交于 2020-01-14 18:46:09
问题 In a Django model that cannot subclass Page , I want to convert an existing ImageField to use Wagtail images. I have redefined the field as: avatar = models.ForeignKey( 'wagtailimages.Image', null=True, on_delete=models.SET_NULL, related_name='+' ) The user needs to be able to upload an image to their profile view. In forms.py for the Django view, I have: avatar = forms.ImageField( label='Your Photo', required=False, error_messages={'invalid': "Image files only"}, widget=forms.FileInput())