Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Page type via Wagtail admin

Tags:

wagtail

I can choose Page type (Page model) in Wagtail admin on creation. This feature is documented: http://docs.wagtail.io/en/latest/editor_manual/new_pages/selecting_a_page_type.html

Is it possible, though, to alter page type in Wagtail admin after the page was created? And is there a way to alter page type programmatically?

like image 768
paramono Avatar asked Oct 13 '17 18:10

paramono


1 Answers

There is no way to alter the page type after it is created using the admin panel in my best knowledge. I have encountered the same problem and I manage to solve it by editing database entry. I am not sure that is the right thing to do or not.

I have mistakenly made a page ('StandardPage' instead of 'StandardIndexPage') and I want to correct it. I can't delete and recreate this page as it has another tree structure below it. So I follow the following steps to change page type.

  • Select the page you want to change and find out its id. Just click on edit then it will open a page like localhost:8000/admin/pages/120/edit/. The number shown will be your id.
  • Select any page which is the type you want to change your page. Then get the id of it.

  • Go to 'wagtailcore_page' table and see the 'content_type_id' of both pages.

  • Double check the content type is correct or not in 'django_content_type' table.

  • Go to the database and check the entries for it in an appropriate table in my case 'home_standardpage'. Double check everything.

  • Go to the new class table where you want to move (home_standardindexpage) and check the requirements. Add an entry with your page id(120 for the above example). Then save the entry.

  • Go to the 'home_standardpage' and delete the entry which you don't want any more(id=120) in the above case.
  • Finally, go to the 'wagtailcore_page' table and find the id (120) and change the 'content_type_id' field to the new page type.

Then that will change your page type. Please take extra care as you are editing in a database. First try it in local replica then only change it in the real product.

like image 128
Bikash kharel Avatar answered Oct 22 '22 03:10

Bikash kharel