wagtail

How to attach js/css to a StreamField block when it is rendered?

时光毁灭记忆、已成空白 提交于 2019-12-01 09:24:43
问题 I know that you can include javascript in the form by using the django forms Media API and the js_initializer() method, and I've done so successfully. But I need to include a javascript and CSS file in the page when an instance of this custom block I've written gets displayed . Is there a specific mechanism for that? Or do I just need to include the js/css files in the Page template? I'd really like to avoid including them on every single Page which has a StreamField that might have this

Wagtail Views: extra context

心已入冬 提交于 2019-11-30 20:31:28
I don't found proper way to update Wagtail CMS Page context. For instance i have my homepage model: class HomePage(Page): about = RichTextField(blank=True) date = models.DateField(auto_now=True) content_panels = Page.content_panels + [ FieldPanel('about', classname="full") ] class Meta: verbose_name = "Homepage" And I also want some third part information to be included on that page. In my case its forum. It will be great to write some ViewMixin, like: class ForumMixin(object): pass # add latest forums to context I can do it by writing my Django CBV, but i really want to know Wagtail Native

Wagtail Views: extra context

我与影子孤独终老i 提交于 2019-11-30 05:45:54
问题 I don't found proper way to update Wagtail CMS Page context. For instance i have my homepage model: class HomePage(Page): about = RichTextField(blank=True) date = models.DateField(auto_now=True) content_panels = Page.content_panels + [ FieldPanel('about', classname="full") ] class Meta: verbose_name = "Homepage" And I also want some third part information to be included on that page. In my case its forum. It will be great to write some ViewMixin, like: class ForumMixin(object): pass # add

collectstatic incorrectly creates multiple CSS files in S3

烈酒焚心 提交于 2019-11-29 13:03:00
I have uploading files to S3 working fine with my Wagtail/django application (both static and uploads). Now I'm trying to use ManifestStaticFilesStorage to enable cache busting. The urls are correctly being generated by the application and files are being copied with hashes to S3. But each time I run collectstatic some files get copied twice to S3 - each with a different hash. So far the issue is ocurring for all CSS files. file.a.css is loaded by the application and is the file referenced in staticfiles.json - however it is a 20.0B file in S3 (should be 6.3KB). file.b.css has the correct

Programatically add a page to a known parent

坚强是说给别人听的谎言 提交于 2019-11-28 12:15:37
I would like to create programatically a sub page for a known parent. How can I do that? The page creation will takes place in a signal receiver: the page is created on publication of another page. Add a revision as well. from wagtail.wagtailcore.models import Page from models import MyPage home = Page.objects.get(id=3) # or better Page query my_page = models.MyPage(title="test", body="<h1>the body</h1>") home.add_child(instance=my_page) # later when a cms user updates the page manually # there will be no first revision to compare against unless # you add a page revision also programmatically.

How can I add an Upload File field to a Wagtail Form?

拜拜、爱过 提交于 2019-11-28 08:58:26
问题 I want to make File Upload a possible Wagtail Form field type on form pages. How do I configure the models to make this possible? Please note I am more interested in allowing users to upload document files like PDFs rather than images. 回答1: Here is a great article from LB Johnson on that matter. The code below is directly taken from the article (but copying here in case the article goes away), however you might want to follow the article as it explains everything step by step. It's quite

Programatically add a page to a known parent

我的未来我决定 提交于 2019-11-27 06:53:44
问题 I would like to create programatically a sub page for a known parent. How can I do that? The page creation will takes place in a signal receiver: the page is created on publication of another page. 回答1: Add a revision as well. from wagtail.wagtailcore.models import Page from models import MyPage home = Page.objects.get(id=3) # or better Page query my_page = models.MyPage(title="test", body="<h1>the body</h1>") home.add_child(instance=my_page) # later when a cms user updates the page manually