django allauth settings.SOCIALACCOUNT_ENABLED overwritten?

15 views Asked by At

django-allauth provides a seettings parameter SOCIALACCOUNT_ENABLED that is used in urls.py to add conditionally socialaccount urls:

allauth/urls.py:

if app_settings.SOCIALACCOUNT_ENABLED:
    urlpatterns += [path("social/", include("allauth.socialaccount.urls"))]

in html templates there is the same parameter used e.g. in

allauth/templates/account/login.html:

{% if SOCIALACCOUNT_ENABLED %}
    {% include "socialaccount/snippets/login.html" with page_layout="entrance" %}
{% endif %}

BUT: in templates it does not reflect settings.SOCIALACCOUNT_ENABLED but is taken from the apps.is_installed status:

allauth/app_settings.py:

class AppSettings(object):

    ....

    @property
    def SOCIALACCOUNT_ENABLED(self):
        return apps.is_installed("allauth.socialaccount")
    
    ....

That means in summary:

   settings.SOCIALACCOUNT_ENABLED  
             -> effect on included allauth url patterns
   settings.INSTALLED_APPS[..., 'allauth.socialaccount'..] 
             -> effect on html templates {% if SOCIALACCOUNT_ENABLED %}  

Can anyone explain why this makes sense??

It did cost me quite some time to understand why templates do not react on "normal" settings parameter.

0

There are 0 answers