wagtail

Wagtail single-page site

夙愿已清 提交于 2020-01-13 05:59:09
问题 I made a single-page site in static HTML with shiny screen-height divs, and a smooth scrolling function from a navbar. The website is expected to have a mixture of simple body text, a few images, and a card-deck. It all worked nicely and I was happy. While I have used wagtail for very simple websites in the past, I cannot work out a way of making a single page site where the home page goes at the top followed by all the child pages in order. Is this possible with Wagtail's page models? 回答1: I

Change href of Live Status link in Wagtail Admin

做~自己de王妃 提交于 2020-01-06 08:21:27
问题 I made a one page scrolling site using wagtail. I have a homepage model and everything else is child pages such as about us, events, etc. On the admin page it creates a slug with the title of the child page which is what the live status link uses. For example it is <a href="/about-us/"> . Is there a way to change the live status link at all? 回答1: The page URL is constructed by calling the get_url_parts method on the page model - by overriding this method, you can customise the resulting URL:

How to break lines when using wagtail BlockQuoteBlock?

为君一笑 提交于 2020-01-06 05:31:06
问题 I have this model: from wagtail.wagtailcore import blocks class BlogPage(Page): date = models.DateField("Post date") intro = RichTextField(blank=True) body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('code', CodeBlock()), ('markdown', MarkDownBlock()), ('media', TestMediaBlock(icon='media')), ('blockquote', blocks.BlockQuoteBlock()) ]) When I'm saving page with some text using blockquote I use

Django, Wagtail admin: handle many to many with `through`

廉价感情. 提交于 2020-01-04 09:15:07
问题 I have 2 models with a through table such as: class A(models.Model): title = models.CharField(max_length=500) bs = models.ManyToManyField(to='app.B', through='app.AB', blank=True) content_panels = [ FieldPanel('title'), FieldPanel('fields'), # what should go here? ] class AB(models.Model): a = models.ForeignKey(to='app.A') b = models.ForeignKey(to='app.B') position = models.IntegerField() class Meta: unique_together = ['a', 'b'] I'm getting the following error when trying to save: Cannot set

Django, Wagtail admin: handle many to many with `through`

て烟熏妆下的殇ゞ 提交于 2020-01-04 09:14:49
问题 I have 2 models with a through table such as: class A(models.Model): title = models.CharField(max_length=500) bs = models.ManyToManyField(to='app.B', through='app.AB', blank=True) content_panels = [ FieldPanel('title'), FieldPanel('fields'), # what should go here? ] class AB(models.Model): a = models.ForeignKey(to='app.A') b = models.ForeignKey(to='app.B') position = models.IntegerField() class Meta: unique_together = ['a', 'b'] I'm getting the following error when trying to save: Cannot set

How to get image url or download url of images in pages API where image is created by a streamfield?

两盒软妹~` 提交于 2020-01-04 04:05:10
问题 In my wagtail application I have a streamfield that is used to upload an image using ImageChooserBlock along with a title and text. That means in the single streamfield I have a title, a text and an image upload inputs. I'm trying to get the image url in the rest framework's pages API ( localhost:8000/api/v2/pages/[page-id] ). But this pages api only gives the image id of the uploaded images as follows { "type": "avengers", "value": { "title": "Tony Stark", "avengers": [ { "image": 1, /******

How do I customize the Wagtail page copy experience?

血红的双手。 提交于 2020-01-04 02:03:47
问题 I have some custom logic (complex unique constraint validation) I would like to check when a user attempts to copy (or move) a certain type of Page in Wagtail. I would also like to give the user an opportunity to change the fields associated with the validation check. I am aware of the fact that Wagtail exposes a way of customizing the copy (and move) experiences through hooks (http://docs.wagtail.io/en/stable/reference/hooks.html#before-copy-page), but the best I can come up with using that

Converting class object to readable value for get_api_representation function

[亡魂溺海] 提交于 2020-01-03 17:34:29
问题 Previous topic where I was kindly helped by @gasman so i have a model class ingredients like: @register_model_chooser class Ingredient(models.Model): name = models.CharField(max_length=255) def __str__(self): return self.name and to represent this in API i created this class: class IngredientChooserBlock(ModelChooserBlock): def get_api_representation(self, value, context=None): if value: return { 'name': value.name, } then i have another model class that uses IngredientChooserBlock class:

Converting class object to readable value for get_api_representation function

雨燕双飞 提交于 2020-01-03 17:33:13
问题 Previous topic where I was kindly helped by @gasman so i have a model class ingredients like: @register_model_chooser class Ingredient(models.Model): name = models.CharField(max_length=255) def __str__(self): return self.name and to represent this in API i created this class: class IngredientChooserBlock(ModelChooserBlock): def get_api_representation(self, value, context=None): if value: return { 'name': value.name, } then i have another model class that uses IngredientChooserBlock class:

Adding a button to Wagtail Dashboard

有些话、适合烂在心里 提交于 2020-01-02 21:19:08
问题 Is it possible to add a additional button( buttons ) on the top panel as shown in the picture? I did't find anything in Google and here. 回答1: It is not clear on the screenshot whether you use modeladmin or the snippet s to expose this model to the user but I'll assume the former. I don't know about a hook which allows you to add buttons directly to the header, however the template uses blocks which should allow us to overwrite just this part. We can take advantage of the resolution order of