Wagtail Support

89 Members
https://github.com/wagtail/wagtail/wiki/Slack#support1 Servers

Load older messages

Timestamp Message
26 Mar 2019
14:49:24@_slack_wagtailcms_U0L1Z4JMC:matrix.orgtom I used our new squash.io setup to try out your fix: https://github.com/wagtail/wagtail/pull/5177#issuecomment-476679646
14:54:10@_slack_wagtailcms_UDH61BSE4:matrix.orgAli joined the room.
14:54:24@_slack_wagtailcms_UDH61BSE4:matrix.orgAli Hi Rinti, thanks, please could you elaborate a bit more?
14:58:03@_slack_wagtailcms_UGG2HD3RU:matrix.orgfabienheureux Did not know squash, this is quite an cool tool !
15:08:59@_slack_wagtailcms_U899CEMD2:matrix.orgrinti https://docs.wagtail.io/en/v2.4/reference/hooks.html#construct-page-chooser-queryset
15:09:05@_slack_wagtailcms_U899CEMD2:matrix.orgrinti There you can change the ordering
15:09:38@_slack_wagtailcms_U899CEMD2:matrix.orgrinti Also. the page tree ordering i don't know where in the documentation that is
15:13:40@_slack_wagtailcms_U0L1Z4JMC:matrix.orgtom it’s new to us too! see https://github.com/wagtail/wagtail/pull/5118
15:18:14@_slack_wagtailcms_UGG2HD3RU:matrix.orgfabienheureux (edited) ... quite an cool ... => ... quite a cool ...
15:20:54@_slack_wagtailcms_UDH61BSE4:matrix.orgAli 👍
17:21:55@_slack_wagtailcms_UE970JJ8Y:matrix.orgNuno Teixeira joined the room.
17:22:01@_slack_wagtailcms_UE970JJ8Y:matrix.orgNuno Teixeira Hi! I have a question related with page editing hooks. I want to get values from a particular field before saving, do the saving and then modify other pages programatically based on previous and newer values of that field.
17:22:37@_slack_wagtailcms_UE970JJ8Y:matrix.orgNuno Teixeira I noticed overriding save_revision and save methods is too late because previous value is already overrided
17:46:12@_slack_wagtailcms_U5M4YK1EF:matrix.orglucasm pre_save will be early enough then right?
17:50:09@_slack_wagtailcms_U5M4YK1EF:matrix.orglucasm I have a question related to the Wagtail api (v2). I defined a custom APIField on a Page (subclass) model, with a custom serializer. It looks like the Pages Endpoint doesn’t use this custom serializer. If I look at the code, the get_serializer_class does notice the custom serializer and writes this relation directly on the class, which seems a bit weird practice to me. The to_representation method of the serializer (BaseSerializer) never makes use of this relation and just uses field.to_representation in all cases. Can anybody confirm, or am I doing something wrong?
17:51:09@_slack_wagtailcms_U5M4YK1EF:matrix.orglucasm (edited) ... the class, which ... => ... the class (`api.v2.serializers.py:353`), which ...
17:52:07@_slack_wagtailcms_U0L1Z4JMC:matrix.orgtom karl ^^
19:11:29@_slack_wagtailcms_UE970JJ8Y:matrix.orgNuno Teixeira lucasm I'm trying to find a place where I can get access before and after saving. In the end I want to get previous values after saving
19:12:19@_slack_wagtailcms_UE970JJ8Y:matrix.orgNuno Teixeira (edited) ... after saving => ... after saving.
19:13:24@_slack_wagtailcms_U0LQA2BFT:matrix.orgmattwestcott nteixeira What if you override save / save_revision, but fetch the existing database entry at the start of the method to retrieve the previous value?
19:15:40@_slack_wagtailcms_UE970JJ8Y:matrix.orgNuno Teixeira mattwestcott those methods are called after form.save() which updates page values. What about trying to get previous revisions?
19:17:06@_slack_wagtailcms_U0LQA2BFT:matrix.orgmattwestcott form.save will update the fields of the in-memory instance, and then call save() on the model. So if you do a database lookup at the start of the model's save method, the database should still contain the previous values
19:20:14@_slack_wagtailcms_UE970JJ8Y:matrix.orgNuno Teixeira mattwestcott aha! Can you give some lights about getting page in context from DB? Should I fetch it from id?
19:22:56@_slack_wagtailcms_U0LQA2BFT:matrix.orgmattwestcott Yes, although bear in mind that the database entry for Page (and subclasses of it) will only get updated on publish, so that will give you the last published version. To get the last version that existed as a draft revision, I think the method is self.get_latest_revision_as_page()
19:24:06@_slack_wagtailcms_UE970JJ8Y:matrix.orgNuno Teixeira I'll give it a try. Thanks a lot!
20:24:46@_slack_wagtailcms_UE970JJ8Y:matrix.orgNuno Teixeira mattwestcott self.get_latest_revision_as_page() on top of save_revision did the job! Thanks 😉
20:32:03@_slack_wagtailcms_U5M4YK1EF:matrix.orglucasm (edited) ... class (`api.v2.serializers.py:353`), which ... => ... class (`api.v2.serializers.py:347`), which ...
20:40:32@_slack_wagtailcms_U5M4YK1EF:matrix.orglucasm ah it makes sense to set it on the class directly I see, only it’s weird that to_representation doesn’t make use of it?
23:08:39@_slack_wagtailcms_UAWRH5X0Q:matrix.orgmarqpdx hi saevar thanks for this. will definitely look into it. i ended up finding this: https://pypi.org/project/django-crequest/ which allows one to grab the request data while over-riding the model's save() method. within the model, it looks like this:
    def save(self, *args, **kwargs):
        crequest = CrequestMiddleware.get_request() #its the current request
        self.author = crequest.user
        super(Blog, self).save(*args,**kwargs)    
Are there any reasons this might be less than ideal? Thanks again,
23:08:52@_slack_wagtailcms_UAWRH5X0Q:matrix.orgmarqpdx (edited) ... Thanks again, => ... Thanks again, m

There are no newer messages yet.

Back to Room List