wagtail

Add StreamBlock child items programmatically in Wagtail

一世执手 提交于 2019-12-06 09:38:37
问题 I have the following StructBlock and StreamBlock below: class AccordionItemBlock(StructBlock): title = CharBlock() text = RichTextBlock() class AccordionRepeaterBlock(StreamBlock): accordion_item = AccordionItemBlock() I need to programmatically add it and multiple "item" CharBlocks to this page: class BasicPage(Page): body = StreamField([ ('accordion_repeater_block', AccordionRepeaterBlock()), ], null=True) This is how I am approaching it page.body = [ ( 'accordion_repeater_block', {

Using python 3.6 on azure app services - not working despite it is installed as extension

落花浮王杯 提交于 2019-12-06 08:02:39
问题 I've got a challenge with deploying Django app (wagtail to be precise) to Azure Web Services using external Git repo (Bitbucket). I want to use Python 3.6.1, therefore I followed instructions at Managing Python on Azure App Service manual I have python 3.6.1 extension installed and in place I created web.config file in root directory of my app (I checked and it is uploaded to the server) However, deploy fails with message Detecting Python runtime from runtime.txt Unsupported runtime: python-3

Wagtail MultiSite - Cross posting content

喜夏-厌秋 提交于 2019-12-06 05:52:14
I am currently building two sites out of a single Wagtail installation. The sites are for a company and it's sister company and there is some overlap in content. Ideally we don't want to have to post the same content twice. In particular we have an Events page on both sites and there may be events that are relevant to both companies. The problem is that a Wagtail page can only exist in one place in the tree at once. I have considered creating a "MirroredEventPage" model with only one foreign key field to the original EventPage model, although this approach has it's problems when it comes to

Making external links open in a new window in wagtail

坚强是说给别人听的谎言 提交于 2019-12-06 02:16:16
问题 I recently implemented adding target="_blank" to external links like this: @hooks.register('after_edit_page') def do_after_page_edit(request, page): if hasattr(page, "body"): soup = BeautifulSoup(page.body) for a in soup.findAll('a'): if hasattr(a, "href"): a["target"] = "_blank" page.body = str(soup) page.body = page.body.replace("<html><head></head><body>", "") page.body = page.body.replace("</body></html>", "") page.body = page.body.replace("></embed>", "/>") page.save() @hooks.register(

Wagtail ModelAdmin read only

陌路散爱 提交于 2019-12-06 01:44:45
Using Wagtails Modeladmin: Is there any way to disable edit & delete options leaving only the inspect view? A possible approach that I can think of, is extending the template, removing the edit & delete buttons and then somehow disable the edit and delete view. Is there any cleaner approach? EDIT: Thanks to Loic answer I could figure out. The PermissionHelper source code was also very helpful to figure out the correct method to override. Complete answer for only showing inspect view class ValidationPermissionHelper(PermissionHelper): def user_can_list(self, user): return True def user_can

Serving static and media files from S3 wagtail

限于喜欢 提交于 2019-12-05 21:04:57
We're going to start using S3 to host our static AND media files. Does anyone have a good link that describes how to do both with wagtail? We're on wagtail 1.9. I can't get both of them to work at the same time. https://wagtail.io/blog/amazon-s3-for-media-files/ Any help greatly appreciated. This blog post on wagtail.io helped me a lot. But what issues are you facing? Can you get it to work separately for both media and static files? Thanks both for responding. I've managed to work it out. To be clear, I want to use the same bucket in S3 to serve my static and my media files for the wagtail

Puput (Wagtail based blog) - Where are the files?

本秂侑毒 提交于 2019-12-05 20:40:22
I've added a puput blog to an existing Django project. I followed all the steps for setting up a standalone blog app ( https://puput.readthedocs.io/en/latest/setup.html ). It works fine in that I now have working blog at http://127.0.0.1:8000/blog/ and can edit the content and add new posts at http://127.0.0.1:8000/blog_admin/ . But where are all the files? Specifically the template file. I don't see any new folders or files in my Django project. I would like to edit the html template in order to get a layout that fits with my project. But I can't find any files to edit. I how someone can help

How can I change the sidebar from Wagtail?

孤者浪人 提交于 2019-12-05 18:49:49
I'm following the Wagtail docs to create a navigation, but it's recommend to use based on 'Snippets', so I would like to change the sidebar to show "Navigation" or "Menu" instead of 'Snippets', is that possible? But when I use just like the docs recommends for sidebar changes: sidebar_content_panels = [ SnippetChooserPanel('advert', Advert), InlinePanel('related_links', label="Related links"), ] So it raises a AttributeError: The sidebar_content_panels code is not relevant here - it demonstrates how you would add an extra tab to the page editor, if your pages contained "main content" and

Wagtail: Filter results of an InlinePanel ForeignKey

南笙酒味 提交于 2019-12-05 16:25:29
These models allow me to establish multiple human "editors" for a tool: class ToolPageEditors(models.Model): person = models.ForeignKey('people.UserProfile') page = ParentalKey('ToolPage', related_name='toolpage_editors') class ToolPage(BaseAsset): content_panels = BaseAsset.content_panels + [ InlinePanel('toolpage_editors', label="Tool Editors") ] But then each ToolPageEditors instance is a dropdown with more than 3,000 users. I'd like to limit the contents of that dropdown to people in a given group. I know how to do this in Django by overriding the admin form, but am having trouble figuring

Wagtail: Get previous or next sibling

﹥>﹥吖頭↗ 提交于 2019-12-05 10:21:25
I'm creating a page with wagtail where I need to know the previous and next sibling of the current page: In my portrait page model, I tried to define two methods to find the correct urls, but I'm missing a crucial part. To get the first sibling, I can just do the following: class PortraitPage(Page): ... def first_portrait(self): return self.get_siblings().live().first().url There is the first() and last() method, but there doesn't seem to be a next() or previous() method to get the direct neighbours (in the order that they are arranged in the wagtail admin). Is there any way to achieve this?