Multiple Sites?

865 views
Skip to first unread message

Dave D

unread,
Mar 22, 2014, 6:12:31 AM3/22/14
to wag...@googlegroups.com
Hello, can wagtail manage multiple sites with one install.

Thanks

Matthew Westcott

unread,
Mar 24, 2014, 7:58:57 AM3/24/14
to wag...@googlegroups.com
Hi Dave,
Yes, this is possible. Within the Wagtail admin you're always working within one overall page tree, but in the Django admin backend (accessible at the URL /django-admin/ in our default/demo install) you can set up any number of Site records, each pointing to a different spot within the tree. Typically you would put all the site homepages at the top level of the tree, although they can go anywhere. Then, whenever a request comes in for a page, it will check the hostname of the request and use that as the starting point when locating the page in the tree.

(It's on our todo list to make this configurable within the Wagtail interface, rather than having to go over to the Django admin.)

- Matthew

Dave D

unread,
Mar 24, 2014, 9:05:17 AM3/24/14
to wag...@googlegroups.com
Hi Matthew, thanks for the reply.

If you don't mind, a quick rundown of my scenario to see if I can use Wagtail.

I'd like to switch some people over from Wordpress to another cms. Hopefully, Wagtail. I need each site to have it's own domain, own template files and it's own "admin." So, basically, multiple sites on Wagtail, each with it's own admin that can only manage their site. Is that doable?

Thanks again, Matthew, Wagtail really looks fantastic!

Dave

Matthew Westcott

unread,
Mar 26, 2014, 4:33:54 PM3/26/14
to Dave D, wag...@googlegroups.com
Hi Dave,

It's *mostly* doable... you can set up permissions to do what you want by creating a separate group for each admin user, and giving that group add, edit and publish permission on the root page of their own site. You'd probably also want to give them 'add' permission (but not 'change' or 'delete') on images and documents, which gives them edit rights over the ones they've uploaded, and nobody else's.

Having different templates per site would need a bit of custom coding... by default, all the page types you define (e.g. BlogPost) are available globally, and each page type corresponds to one template file. Assuming your data model is the same across all sites (that is, a BlogPost on site A would consist of the same fields as a BlogPost on site B) you could achieve this by defining one common BlogPost class for all sites, with a bit of logic to switch the base template depending on whereabouts the page is within the tree. Roughly speaking, it would go something like:

class BlogPost(Page):
body = RichTextField()
# other field definitions here...

def base_template(self):
if self.url_path.startswith('/site-a/'):
return "layouts/site_a.html"
elif self.url_path.startswith('/site-b/'):
return "layouts/site_b.html"
else:
return "layouts/site_c.html"


and at the top of blog_post.html:

{% extends self.base_template %}


Cheers,
- Matthew
> --
> You received this message because you are subscribed to the Google Groups "Wagtail" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wagtail+u...@googlegroups.com.
> To post to this group, send email to wag...@googlegroups.com.
> Visit this group at http://groups.google.com/group/wagtail.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/wagtail/edc35dfe-e0cf-4e59-80c0-743e32c7998f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Tom Dyson

unread,
Mar 27, 2014, 6:41:35 AM3/27/14
to wag...@googlegroups.com
Hi Dave

As a less elegant alternative to Matthew's suggested approach, it's also possible for you to simply create multiple Wagtail apps - roughly analogous to multiple WordPress sites - as distinct Django apps, each with its own database, but all referencing the same Wagtail package.

Good luck!

Tom
Reply all
Reply to author
Forward
Message has been deleted
0 new messages