Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Social Authentication and ContentTypes #43

Open
telenieko opened this issue Feb 28, 2019 · 2 comments
Open

Social Authentication and ContentTypes #43

telenieko opened this issue Feb 28, 2019 · 2 comments

Comments

@telenieko
Copy link

Hi,

If you follow the doc about socialauth you will end up with a non working setup, at least when enabling google OAuth2

Traceback (most recent call last):
  File "manage.py", line 28, in <module>
    execute_from_command_line(sys.argv)
  ...
  File "lib/python3.6/site-packages/social_django/urls.py", line 6, in <module>
    from . import views
  File "lib/python3.6/site-packages/social_django/views.py", line 10, in <module>
    from .utils import psa
  File "lib/python3.6/site-packages/social_django/utils.py", line 18, in <module>
    Strategy = module_member(STRATEGY)
  File "lib/python3.6/site-packages/social_core/utils.py", line 61, in module_member
    module = import_module(mod)
  File "lib/python3.6/site-packages/social_core/utils.py", line 55, in import_module
    __import__(name)
  File "lib/python3.6/site-packages/social_django/strategy.py", line 5, in <module>
    from django.contrib.contenttypes.models import ContentType
  File "lib/python3.6/site-packages/django/contrib/contenttypes/models.py", line 134, in <module>
    class ContentType(models.Model):
  File "lib/python3.6/site-packages/django/db/models/base.py", line 95, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

The solution looks obvious: add contenttypes to INSTALLED_APPS. Which you could do in two forms:

  • You see the error, you are an experienced Django developer so, after instantiating Site() you add:
INSTALLED_APPS += ('django.contrib.contenttypes',)

And you will be greeted with...

table_factory() failed for <class 'django.contrib.contenttypes.models.ContentType'>.
table_factory() failed for <class 'django.contrib.contenttypes.models.ContentType'>.

Only then will you think "hey, it's not a plugin, but maybe the right place to put it is Site.get_installed_apps, like: yield 'django.contrib.contenttypes'.

Now it works.

So, that page might explain that contenttypes is needed, and how to add it?

@lsaffre
Copy link
Member

lsaffre commented Feb 28, 2019

How did you get that error? I cannot reproduce it. What is your output of pip freeze?

@telenieko
Copy link
Author

pip freeze:

alabaster==0.7.12
appnope==0.1.0
argh==0.26.2
args==0.1.0
astroid==2.2.0
atelier==1.1.12
atomicwrites==1.3.0
attrs==18.2.0
Babel==2.6.0
backcall==0.1.0
beautifulsoup4==4.7.1
bleach==3.1.0
BTrees==4.5.1
cachetools==3.1.0
cairocffi==1.0.2
CairoSVG==2.3.0
certifi==2018.11.29
cffi==1.12.2
chardet==3.0.4
clint==0.5.1
coverage==4.5.2
cssselect2==0.2.1
dateparser==0.7.1
DateTime==4.3
decorator==4.3.2
defusedxml==0.5.0
Django==2.1.5
django-environ==0.4.5
django-localflavor==2.1
django-storages==1.7.1
docutils==0.14
et-xmlfile==1.0.1
etgen==0.0.5
future==0.17.1
gitdb2==2.0.5
GitPython==2.1.11
google-api-core==1.8.0
google-api-python-client==1.7.8
google-auth==1.6.3
google-auth-httplib2==0.0.3
google-cloud-core==0.29.1
google-cloud-storage==1.14.0
google-resumable-media==0.3.2
googleapis-common-protos==1.5.8
html2text==2018.1.9
html5lib==1.0.1
httplib2==0.12.0
idna==2.8
imagesize==1.1.0
invoke==1.2.0
ipython==7.3.0
ipython-genutils==0.2.0
isort==4.3.9
jdcal==1.4
jedi==0.13.3
Jinja2==2.10
lazy-object-proxy==1.3.1
lino==19.2.2
lino-xl==19.2.0
lxml==4.3.1
MarkupSafe==1.1.1
mccabe==0.6.1
metanube-imegapy==0.0.12
more-itertools==6.0.0
numpy==1.16.1
oauthlib==3.0.1
odfpy==1.4.0
openpyxl==2.6.0
packaging==19.0
pandas==0.24.1
parso==0.3.4
persistent==4.4.3
pexpect==4.6.0
phonenumbers==8.10.6
pickleshare==0.7.5
Pillow==5.4.1
pluggy==0.9.0
prompt-toolkit==2.0.9
protobuf==3.6.1
psycopg2==2.7.7
ptyprocess==0.6.0
py==1.8.0
pyasn1==0.4.5
pyasn1-modules==0.2.4
pycparser==2.19
Pygments==2.3.1
PyJWT==1.7.1
pylint==2.3.0
pyparsing==2.3.1
Pyphen==0.9.5
pytest==4.3.0
pytest-cov==2.6.1
python-dateutil==2.8.0
python-stdnum==1.10
python3-openid==3.1.0
pytidylib==0.3.2
pytz==2018.9
PyYAML==3.13
regex==2019.2.21
reportlab==3.5.13
requests==2.21.0
requests-oauthlib==1.2.0
rsa==4.0
schedule==0.5.0
six==1.12.0
smmap2==2.0.5
snowballstemmer==1.2.1
social-auth-app-django==3.1.0
social-auth-core==3.1.0
soupsieve==1.8
Sphinx==1.8.4
sphinxcontrib-websupport==1.1.0
tinycss2==0.6.1
traitlets==4.3.2
transaction==2.4.0
typed-ast==1.2.0
tzlocal==1.5.1
Unipath==1.1
uritemplate==3.0.0
urllib3==1.24.1
wcwidth==0.1.7
WeasyPrint==45
webencodings==0.5.1
wrapt==1.11.1
xxhash==1.3.0
zc.lockfile==1.4
ZConfig==3.4.0
ZODB==5.5.1
zodbpickle==1.0.3
zope.interface==4.6.0

I'm on python 3.6.8

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants