pythondjangodjango-allauthwagtailsites

Django Wagtail Project - Conflict with django.contrib.sites (using django-allauth)


I'm running into issues when adding a 3rd party 'user accounts' app to a Wagtail project.

Most 3rd party user account apps (such as django-alluth) require django.contrib.sites as a dependency.

When I include the django-allauth dependencies (including the required django.contrib.sites) in INSTALLED_APPS, along with wagtail.wagtailsite app, I run into issues with the site loading correctly (static files don't load correctly, for example). I am unable to track down exactly what isn't loading correctly, but from what I can tell, it is a runtime conflict between the wagtail 'sites' app and the django 'sites' app.

It seems like there should be a way to have wagtail and django-allauth running side-by-side... Does anyone have django-alluth and wagtail working nicely together? Is it possible and what did you need to do?

Any tips or examples of django-alluth and Wagtail working together are greatly appreciated.

Versions: Django 1.10.1, Wagtail 1.8

EDIT:

Okay, I found why my static files aren't loading correctly when I Have all the django-allauth dependencies in place. It looks like my projects base.html file that usually gets called is getting superseded by the baste.html in the allauth package. I'll need to prevent the django-allauth base.html file from being called. Here's the django-allauth base.html that is overwriting my usual html section:

 <!DOCTYPE html>
<html>
  <head>
    <title>{% block head_title %}{% endblock %}</title>
    {% block extra_head %}
    {% endblock %}
  </head>
  <body>
    {% block body %}

    {% if messages %}
    <div>
      <strong>Messages:</strong>
      <ul>
    {% for message in messages %}
    <li>{{message}}</li>
    {% endfor %}
      </ul>
    </div>
    {% endif %}

    <div>
      <strong>Menu:</strong>
      <ul>
    {% if user.is_authenticated %}
    <li><a href="{% url 'account_email' %}">Change E-mail</a></li>
    <li><a href="{% url 'account_logout' %}">Sign Out</a></li>
    {% else %}
    <li><a href="{% url 'account_login' %}">Sign In</a></li>
    <li><a href="{% url 'account_signup' %}">Sign Up</a></li>
    {% endif %}
      </ul>
    </div>
    {% block content %}
    {% endblock %}
    {% endblock %}
    {% block extra_body %}
    {% endblock %}
  </body>
</html>

I'm going to look into how to fix this now. If you know how, that would be an acceptable answer :)


Solution

  • The solution to this problem was to include these INSTALLED_APPS after my project specific apps:

    ...
    'myApp1'
    ...
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    

    This prevented the allauth base.html from being used, and my 'myApp1' base.html loading correctly.

    I didn't realize that the order of INSTALLED_APPS effects the loading behaviour.

    Thanks.