4

This may be a basic question, but it puzzles me and I couldn't find an answer on the web. In my Wagtail admin I see a menu entry 'Sites' with (in my case) one item, in which I can configure a host name, a port, a site name, a Wagtail root page and a boolean 'is default site'. When I log in to django-admin (for the same project obviously) I see a menu entry 'Sites' with one item, with only two fields: domain name, display name. Changing it in one admin doesn't seem to change anything in the other. E.g. I needed to change the domain name (default in Django 'example.com') but couldn't find that in Wagtail admin.

Are the two related in some way, and if so, why don't I see the same fields on both admins? Am I missing something obvious?

Paul Rene
  • 680
  • 4
  • 14

1 Answers1

5

While both Wagtail and Django have a framework approach to a Site, they are actually different things, with different database models and usage.

Django Site

  • An open ended way to represent multiple sites in a Django application and part of the contrib models that come with Django.
  • Wagtail does not use the Django sites framework out of the box, but some other Django applications do.
  • Docs - https://docs.djangoproject.com/en/3.0/ref/contrib/sites/

Wagtail Site

  • A more specific model built for Wagtail's representation of sites, it does not inherit or use the Django Sites framework.
  • Example - Wagtail's Page model is related to one Site only, this being a Wagtail site, but Image is not related to a Site and hence can easily be shared across multiple sites.
  • Docs - https://docs.wagtail.io/en/latest/reference/pages/model_reference.html#site

Version 2.9 Change

  • To avoid redundant database queries and potential clashes with Django’s Sites framework, Wagtail made a change to how SiteMiddleware was used.
  • You can see the full context of this and potential causes of bugs and confusion on this Github issue - https://github.com/wagtail/wagtail/issues/2840
LB Ben Johnston
  • 4,751
  • 13
  • 29
  • Thank you LB, that is very useful, especially the discussion on the Wagtail Github pages. I've been using allauth and Wagtail (only one site), wasn't aware of this issue. – Paul Rene Apr 16 '20 at 08:16
  • No problems, it is a bit confusing but as you can see in the discussion they serve different purposes and hence cannot really be 'merged' into the one thing, even if in hindsight it adds some indirection for developers. – LB Ben Johnston Apr 16 '20 at 10:43