Programmatically update page fields

153 views
Skip to first unread message

Tim Claes

unread,
Apr 14, 2016, 12:41:08 PM4/14/16
to Wagtail support
Hi,

I have a requirement where I want to programmatically set a ForeignKey field for a Page model. So I create an instance of the ForeignKey model and assign it to the page, but the changes do not reflect in the editing interface. How could I update the interface along with any page updates?

Thank you!

Brett Grace

unread,
Apr 29, 2016, 4:59:42 PM4/29/16
to Wagtail support
Any time you change a Page model (including its relations), you need to call my_page.save_revision().publish(). See https://github.com/torchbox/wagtail/issues/1101
Reply all
Reply to author
Forward
0 new messages