wagtail

Django Rest Framework does not show content from StreamField

♀尐吖头ヾ 提交于 2019-12-24 00:49:43
问题 I have a model class with ModelChooserBlock inside StreamField and If I open my Django Rest Framework I don't get a satisfactory result. Specifically "Ingredient" should have a link to ingredients or directly Database. HTTP 200 OK Allow: GET, HEAD, OPTIONS Content-Type: application/json Vary: Accept { "id": 1, "meta": { "type": "cultinadb.Menu", "detail_url": "http://127.0.0.1:8000/api/v2/menu/1/" }, "title": "", "Ingredient": [ { "type": "zutaten", "value": 2, "id": "647d762f-ec26-4c78-928a

Get parent page on creating new Wagtail Page

こ雲淡風輕ζ 提交于 2019-12-23 16:36:59
问题 I need to change some field default value given a value from the parent page when creating a new page. When editing an existing page, this is not a problem, but when creating a new page, I need to set a default value for a field. I have tried overriding the admin form, on init for WagtailAdminPageForm, the parent_page parameter is empty. And if I try to do it on the init method form Page subclass, there is no arg or kwargs with the parent information. is there a way to get the page for which

How to join wagtail and django sitemaps?

安稳与你 提交于 2019-12-23 15:28:42
问题 I'm using wagtail app in my Django project. Is it possible to join django sitemaps (https://docs.djangoproject.com/en/1.11/ref/contrib/sitemaps/) with wagtail sitemaps (wagtail.contrib.wagtailsitemaps)? Tried using django sitemap indexes, but it divide only django sitemap, how I can include wagtail sitemap? 回答1: Wagtail uses the Django sitemap framework since version 1.10. This should allow you to easily combine regular Django sitemaps with Wagtail sitemaps. There is a small catch however;

Converting value to json inside serve method. Wagtail

江枫思渺然 提交于 2019-12-23 04:22:46
问题 I realy tried to find answer to my question, but don't know what should I do. I found following question and they didn't help me. question1, question2, docs I got different values with different functions that I used. Sometimes None value sometimes TypeError: Object of type 'method' is not JSON serializable and AttributeError: 'str' object has no attribute 'status_code' and this TypeError: 'method' object is not iterable But i didn't still find solution to solve my problem. Here is my Page

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

萝らか妹 提交于 2019-12-22 10:37:53
问题 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

Wagtail ModelAdmin read only

China☆狼群 提交于 2019-12-22 09:38:18
问题 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

Wagtail getting/generating image urls from JSON api or directly

天涯浪子 提交于 2019-12-22 08:53:00
问题 I've been using Wagtail as a headless CMS to use with a frontend application, However I noticed some limitations regarding images. Normally in your jinja template you would generate the correct image size you need and all is fine, However I don't have access to these helpers in my frontend code. I have been trying several things. for example, to solve this for simple page models and their fields I could render a custom api field like so: api_fields = [ # Adds information about the source

How to modify wagtail CMS so that any user can post blog posts under their own blog

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 01:06:29
问题 I have an existing website that is a Django App. I have installed Wagtail, and the Wagtail CMS is now accessible at www.example.com/cms . Wagtail is working correctly with my database, and all the existing users are visible when I go to settings and then users , in the wagtail CMS admin page. I want to use Wagtail to add blog functionality to my website. Requirements I want any user to be able to create a new blog and add posts to their blog. I want the blog created by a user to be visible at

Wagtail, how do I populate the choices in a ChoiceBlock from a different model?

喜你入骨 提交于 2019-12-21 17:26:07
问题 This is the model for icons displayed on top of a text, they get a name and the icon. from django.db import models from django.utils.translation import ugettext as _ from django.conf import settings class SomeSortOfIcon(models.Model): name = models.CharField(max_length=200, verbose_name=_('Icon Name'), help_text=_('This value will be shown to the user.')) image = models.ForeignKey( getattr(settings, 'WAGTAILIMAGES_IMAGE_MODEL', 'wagtailimages.Image'), on_delete=models.PROTECT, related_name='+

Wagtail: Get previous or next sibling

不想你离开。 提交于 2019-12-21 16:54:31
问题 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