wagtail

How do you unregister a model in wagtail modeladmin?

∥☆過路亽.° 提交于 2019-12-20 01:41:50
问题 I need to do the equivalent of... 'admin.site.unregister(Value)' but for a model registered with wagtailmodeladmin using 'modeladmin_register(Value)' in wagtail_hooks.py. How do you do that? 回答1: I know this is an old question, but the short answer is "There is no unregister equivalent". In standard Django, all the models you see in Django's admin area have been registered in a similar fashion, so unregister makes sense there. In Wagtail, the admin area is completely custom, and 'modeladmin'

collectstatic incorrectly creates multiple CSS files in S3

点点圈 提交于 2019-12-18 07:21:16
问题 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

Using or Q() objects in limit_choices_to in wagtailadmin

左心房为你撑大大i 提交于 2019-12-14 03:53:09
问题 Django 1.10.5 def limit_contributor_choices(): limit = Q(group__name="contributor") | Q(group__name="Group") return limit author = models.ForeignKey( settings.AUTH_USER_MODEL, blank=True, null=True, limit_choices_to=limit_contributor_choices, verbose_name=_('Author'), on_delete=models.SET_NULL, related_name='author_pages', ) With the following code, if a user is in more than one group, then the query returns that user multiple times. How do I get distinct values? I'm using this in the wagtail

How to add multi-level menu support to wagtail (with support for non-wagtail based pages)

ε祈祈猫儿з 提交于 2019-12-13 18:33:07
问题 How can I add support for custom menus which will work also with non-Wagtail based pages. For example by giving directly a relative url to a registration page such as '/account/registration') For example by giving directly an absolute url to an external page such as 'www.stackoverflow.com' I found this very interesting project: https://github.com/rkhleics/wagtailmenus Unfortunately is does not support submenus in the main menu. 回答1: One thing about Wagtail is that what I would call the data

Wagtail ModelAdmin. Several sections for custom User

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 16:57:21
问题 I'm trying to set up Wagtail for existing custom User model. As per requirements several User pages should be available, representing different types of users (Regular, Manager, etc) I tried to make separate ModelAdmin for each case, overriding get_queryset for filtering by user type. But it looks like all of them show the first definition of ModelAdmin, as all of them has model - User Then I tried to use Proxy model, in this case there is no display at all, as Wagtail seemingly doesn't

Wagtail admin ,CheckboxSelectMultiple not saving data

血红的双手。 提交于 2019-12-13 16:05:58
问题 @register_snippet class Numbers(models.Model): number = models.IntegerField() class State(models.Model): state = models.CharField(max_length=100) number = ParentalManyToManyField(Numbers) class HomeStateNumber(State): page = ParentalKey('home.HomePage', related_name='helpline') api_fields = ['state', 'number'] panels = [ FieldPanel('state'), FieldPanel('number',widget=forms.CheckboxSelectMultiple), ] class HomePage(Page): content_panels = [ FieldPanel('title'), ImageChooserPanel('cover_page')

how to i can change wagtail cms page tag before save

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 07:07:50
问题 How can I change wagtail page tag before saving? I can change the title by overriding save() like this- class ProductPageTag(TaggedItemBase): content_object = ParentalKey('product.ProductPage',related_name='tagged_items') class ProductPage(Page): body = StreamField(BodyStreamBlock) tags = ClusterTaggableManager(through=ProductPageTag, blank=True) def save(self, *args, **kwargs): self.title = "my title" # work self.tags = "test,test2,test3" #not work super(ProductPage, self).save() but I don't

Wagtail Menu generates incorrect Custom URL

ぐ巨炮叔叔 提交于 2019-12-13 04:24:47
问题 I have a conventional Wagtail Main Menu bar with one exception. One Menu entry points to a URL supported by a Django TemplateView. In the menu in Wagtail Admin, the menu item uses the custom URL instead of specifying an internal page. If I do a View Live from the Wagtail admin to the top level page then select the Django page, it works as expected. However, if I am somewhere within the site and click on the menu item, it generates a url that is the URL of the page I happen to be on with the

Access StructBlock in a StreamField of a Page.get_children in Wagtail

拈花ヽ惹草 提交于 2019-12-13 03:54:24
问题 I try to render a StreamField of a child page in a Page. I don't manage to render the different StructField within the StreamField. Here is my code class DefinitionPage(Page): body = StreamField([ ('definition', blocks.StructBlock([ ('heading', blocks.CharBlock(label='Titre')), ('paragraph', blocks.RichTextBlock(label='Paragraphe')), ])) ]) content_panels = Page.content_panels + [ StreamFieldPanel('body'), ] my template. (DefinitionPage is a child of this page.) {% for post in page.get

How to prevent duplicates when using ModelChoiceFilter in Django Filter and Wagtail

做~自己de王妃 提交于 2019-12-13 03:36:10
问题 I am trying to use filters with a Wagtail Page model and a Orderable model. But I get duplicates in my filter now. How can I solve something like this? My code: class FieldPosition(Orderable): page = ParentalKey('PlayerDetailPage', on_delete=models.CASCADE, related_name='field_position_relationship') field_position = models.CharField(max_length=3, choices=FIELD_POSITION_CHOICES, null=True) panels = [ FieldPanel('field_position') ] def __str__(self): return self.get_field_position_display()