Search code examples
djangodjango-adminwagtailwagtail-admin

Difference between Wagtail admin Site and Django admin Site?


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?


Solution

  • 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