Q:

Wagtail Page create via model_mommy

I'm trying to create some tests for my first Django site.   One thing that is burdensome is creating example pages for testing (at least you have to specify a lot of parameters and some (such as ContentType) are not always obvious.   More generally, I'd like to use Model Mommy to create many of the objects I need.  
Near as I can tell, it can't create an instance of a Page (claiming that a "Page matching query does not exist").   [the test case is a simple import of Page and Model Mommy then create an instance of a page]. 
I'm not sure if this is properly an issue for Wagtail or for Model Mommy, but debugging it is getting  a bit out of my depth and it would be very useful if it could work. 
Unless there is something obvious I'm missing or can/should do,  I'm posting this more to flag the problem than to try to get a solution right now. 
Thx,
    --Don

A:

Mommy doesn't handle Django Tree Beard relations.  Tree Beard is the package used by Wagtail to create the page tree. 
Mommy doesn't create the tree structure correctly.  You should add your pages to the tree yourself.  You can do this with add_child. 
Root is created by the Wagtail migrations: https://github.com/wagtail/wagtail/blob/master/wagtail/core/migrations/0002_initial_data.py#L13-L38
There is no need to set the content type manually if you use your specific class directly.  I used FooPage in the example below. 
from wagtail.wagtailcore.models import Page
from app.models import FooPage

root = Page.objects.get(slug='root')
page = FooPage(title='Example', ...)
root.add_child(instance=page)

