Howto transfer existing home page into Wagtail

713 views
Skip to first unread message

David Herring

unread,
Apr 27, 2017, 8:26:02 AM4/27/17
to Wagtail support
We have an application for Visitor management written in Django (https://visitor.express). Once you login all the pages are 'dynamic'.

Two questions;-

1. How do you transfer an existing page into Wagtail ? In our case the homepage of Visitor.Express

2. Is this a sensible way to start using Wagtail for the static pages around the Visitor.Express service, and any documentation / pointers on integrating Wagtail with an existing app would be welcome.

I will call Torchbox on this, would like to use an 'expert' to initially assist / advise us if this is sensible / and how best to go about this.

Thanks Dave

Matthew Westcott

unread,
Apr 28, 2017, 11:38:12 AM4/28/17
to wag...@googlegroups.com
Hi Dave,

http://docs.wagtail.io/en/v1.9.1/getting_started/integrating_into_django.html is your best starting point for integrating Wagtail into an existing Django app. Note in particular the different options for where to put the `wagtail_urls` URL configuration - to have Wagtail handle the homepage, you'll want to use:

url(r'', include(wagtail_urls)),

placed at the end of the URL config, so that your app's existing URL routes take precedence.

To convert an existing (fully static) homepage into a Wagtail page, the approach I'd take would be:

* Create a `home` app in your project, if you don't have one already
* Define an empty `HomePage` page model in /home/models.py (and then run makemigrations / migrate):

from wagtail.wagtailcore.models import Page

class HomePage(Page):
pass

* Move/copy the existing homepage template to /home/templates/home/home_page.html
* Within the Wagtail admin, delete the initial dummy homepage, and create and publish a new HomePage
* Set up a site record (under Settings -> Sites) pointing to the newly created page as the site root

You can then proceed to add editable fields to the HomePage model, incrementally replacing the existing hard-coded template content. If your existing homepage isn't pure static HTML but contains custom view code, you can move this into a `get_context` method on the page model:

http://docs.wagtail.io/en/v1.9.1/topics/pages.html#customising-template-context

Cheers,
- Matt

David Herring

unread,
Apr 30, 2017, 7:31:44 PM4/30/17
to wag...@googlegroups.com

Thanks for the help Matthew.

Have followed your steps but do not see the 'HomePage' in the '/cms' admin area ?

Must be missing something here.

Any guidance appreciated, Dave

--
You received this message because you are subscribed to a topic in the Google Groups "Wagtail support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wagtail/K3yZVS-HY7Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wagtail+unsubscribe@googlegroups.com.
To post to this group, send an email to wag...@googlegroups.com.
Visit this group at https://groups.google.com/group/wagtail.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wagtail/97B81ABB-9127-495B-81A6-9152309228A8%40torchbox.com.
For more options, visit https://groups.google.com/d/optout.



--
David Herring

Matthew Westcott

unread,
May 2, 2017, 7:36:55 AM5/2/17
to wag...@googlegroups.com
Do you get a page like http://docs.wagtail.io/en/v1.9.1/_images/tutorial_2.png ? Clicking on Explorer or "1 Page" should take you to the right place. After you've deleted the initial dummy homepage, you should get the option "Add child page".

Cheers,
- Matt
> To unsubscribe from this group and all its topics, send an email to wagtail+u...@googlegroups.com.

David Herring

unread,
May 8, 2017, 7:07:34 PM5/8/17
to Wagtail support
Thanks for the help, now have the homepage working as you stated.
Reply all
Reply to author
Forward
0 new messages