doableware / djongo

Django and MongoDB database connector
https://www.djongomapper.com
GNU Affero General Public License v3.0
1.88k stars 355 forks source link

Django (sites.E101) The SITE_ID setting must be an integer #618

Open Jcbobo opened 2 years ago

Jcbobo commented 2 years ago

One line description of the issue

(sites.E101) The SITE_ID setting must be an integer

Python script

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
]
SITE_ID = '627cb66b6546163cb291f918'

Traceback

 Exception in thread django-main-thread:
 Traceback (most recent call last):
   File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
     self.run()
   File "/usr/local/lib/python3.9/threading.py", line 910, in run
     self._target(*self._args, **self._kwargs)
   File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
     fn(*args, **kwargs)
   File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 134, in inner_run
     self.check(display_num_errors=True)
   File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 558, in check
     raise SystemCheckError(msg)
 django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

 ERRORS:
 ?: (sites.E101) The SITE_ID setting must be an integer
Hajime8673 commented 2 years ago

Go to your MongoDB database, and then collection named django_site, then remove existing one and manually add a new document with "_id": 1. You can also just simply clone the existing one and just change "_id": ObjectID("...") to int32 and set the _id to 1. Just like this

And now you can set SITE_ID = 1 in settings.py