wagtail

How can I access request object in the wagtail Page model?

大兔子大兔子 提交于 2019-12-08 04:12:57
问题 I wanna dynamically set default value of the field to the currently logged in user: class SimplePage(Page): author = models.CharField(max_length=255, default=request.user) I know about get_context , but class attributes cannot call instance methods. def get_context(self, request, *args, **kwargs): return { PAGE_TEMPLATE_VAR: self, 'self': self, 'request': request, } Any more ideas? Essentially whoever is logged in into the admin should become author's default. 回答1: I got part way there but am

Generating a unique list of Django-Taggit Tags in Wagtail;

拥有回忆 提交于 2019-12-08 02:41:19
问题 I am trying to add a list of category tags in the sidebar of my Wagtail blog index page. The code below does work, but unfortunately it iterates through the posts and lists all the tags as individual tags, which I ultimately end up with duplicate tags. I built my blog from the Wagtail demo and since it doesn't use Views like I am used to, I am not sure where to add .distinct('tags'). Template {% for b in blogs %} {% for tag in b.tags.all %} <li><a href="{% pageurl b.blog_index %}?tag={{ tag }

Wagtail Custom Document Model

≯℡__Kan透↙ 提交于 2019-12-07 19:13:48
问题 I understand from this thread https://github.com/wagtail/wagtail/issues/2001 that you can customise the Wagtail Document Model, as you can the Image Model, to add extra fields to it. What I can't find is any documentation on how to do this. If anyone has any suggestions on where to start that would be great. I'm new to wagtail so any help much appreciated. Thanks! 回答1: Custom document model can be implemented in a similar way as a custom image model. To add your own document model (let's call

create collection with python code

故事扮演 提交于 2019-12-07 17:59:31
i would like to make a model that will allow the user in the Wagtail admin site to choose a directory of images give the name of the collection in a CharField and upon a button press a collection with the given name would be created, then the images from a the given directory would then be saved to the database (so that they are avaialable in the CMS). The title of the image would be it's filename, while it's tag would be the directory name where the image is found. I found another post on how to save Images to the database with code ( image saving ) but I have a problem creating collections

How can I change the sidebar from Wagtail?

♀尐吖头ヾ 提交于 2019-12-07 13:53:13
问题 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: 回答1: The sidebar_content_panels code is not relevant here - it

Serving static and media files from S3 wagtail

被刻印的时光 ゝ 提交于 2019-12-07 12:32:20
问题 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. 回答1: 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? 回答2: Thanks both for responding. I've managed to work

Adding bootstrap img-responsive class to wagtail WYSIWYG editor

耗尽温柔 提交于 2019-12-07 12:26:59
问题 I am trying to make it so that when a body image is inserted into a page, that the bootstap class "img-responsive" is added to the image tag? Can anyone tell me how to achieve this? 回答1: You can do this through image formats: http://docs.wagtail.io/en/v0.8.5/core_components/pages/editing_api.html#image-formats-in-the-rich-text-editor The "Full width" / "Left-aligned" / "Right-aligned" options you usually get when inserting an image into the rich text area come from Format objects, which

Adding a button to Wagtail Dashboard

試著忘記壹切 提交于 2019-12-06 15:57:11
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. 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 the templates and create /modeladmin/app-name/model-name/index.html which will take precedence over

Wagtail per page user permission

≡放荡痞女 提交于 2019-12-06 10:34:15
问题 My task is to enable users to edit their own page. I see how to give permissions to a particular page to a group, but how do I do this for the user? I'd tried use django guardian: UserObjectPermission.objects.assign_perm('change_custompage', user, obj=custompage) but this wasn't given me results I also found the wagtailcore_grouppagepermission table and realized that the permissions principle is not the same as used in django auth_permission I want to give permissions to edit, and access

Wagtail Custom Document Model

China☆狼群 提交于 2019-12-06 10:07:43
I understand from this thread https://github.com/wagtail/wagtail/issues/2001 that you can customise the Wagtail Document Model, as you can the Image Model, to add extra fields to it. What I can't find is any documentation on how to do this. If anyone has any suggestions on where to start that would be great. I'm new to wagtail so any help much appreciated. Thanks! Custom document model can be implemented in a similar way as a custom image model . To add your own document model (let's call it CustomDocument ) you should do the following: Create a model that inherit from wagtail.wagtaildocs