I'm following the docs of django-allauth for installation, but I'm unable to manage.py migrate. I've included 'django.contrib.sites' in my INSTALLED_APPS, and SITE_ID = 1, but I get the error
django.db.utils.ProgrammingError: relation "django_site" already exists
I'm running Django 2.1.5.
I can't find anything about "django_site" already exists, only "django_site" does not exist.
What I have in installed apps, excluding internal apps:
INSTALLED_APPS = (
'authtools',
'lot',
'bootstrap4',
'storages',
'oauth2_provider',
'bootstrap_pagination',
'dal',
'cloudinary',
'django_extensions',
'django_filters',
'reversion',
'constance',
'constance.backends.database',
'rest_framework',
'django_gravatar',
'messages_extends',
'cq',
'futon',
'memoize',
'jam',
'drf_aggregates',
'batch_requests',
'webpack_loader',
'django_prometheus',
# Core
'django.contrib.sites',
'django.contrib.postgres',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
# Channels
'channels',
'channels_redis',
# allauth
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
)
So it turns out I had previously had django.contrib.sites as an INSTALLED_APP before, so the migration failed. Fix was just to run ./manage.py migrate --fake-initial
Try this
python manage.py migrate sites
python manage.py migrate
In INSTALLED_APPS keep 'django.contrib.sites' at top.
Related
new to django
django version : Django==2.2
getting below error :
Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
while running below commands:
python3.7 manage.py collectstatic
python3.7 manage.py shell
python3.7 manage.py runserver
below is what my INSTALLED_APPS look like
INSTALLED_APPS = (
'actions.apps.MyAppConfig',
'common.apps.MyAppConfig',
'hotels.apps.MyAppConfig',
'extranet.apps.MyAppConfig',
'communication.apps.MyAppConfig',
'bulk_uploader.apps.MyAppConfig',
'registration.apps.MyAppConfig',
'channel_manager.apps.MyAppConfig',
'reports.apps.MyAppConfig',
'mobile.apps.MyAppConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'admin_shortcuts',
'guardian',
'actstream',
'rest_framework',
'django_filters',
'rest_framework.authtoken',
'oauth2app',
'ckeditor',
'stats',
'django_celery_beat',
)
any suggestion?
I encountered an error while trying to make migration. I reinstalled the app yet i still saw the same error.
Here is my setting file:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# 3rd Party
'rest_framework',
'rest_framework.authtoken',
'allauth',
'allauth.account',
'alluth.socialaccount',
'rest_auth',
'rest_auth.registration',
# Local
'posts.apps.PostsConfig',
]
# Peculiar to django-allauth app
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
SITE_ID = 1
This is the error am getting when i run python manage.py migrate:
ModuleNotFoundError: No module named 'alluth'
The problem lies in 3rd party section of INSTALLED APPS.
'alluth.socialaccount'
it is a typo, it should be
'allauth.socialaccount',, pay attention to alluth -> allauth
When I try to log in to admin section I get the error page:
http://localhost:8000/admin/
ProgrammingError at /admin/ ERROR: relation "django_admin_log" does
not exist
Then I noticed that 'django_admin_log' table does not exist.
captured from psql
I can not remember whether I accidentally removed it or not.
In order to recover it I checked "django.contrib.admin" is in INSTALLED_APPS in settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'db.apps.DbConfig',
'django.contrib.postgres',
'accounts.apps.AccountsConfig',
'django.contrib.sites',
'allauth',
'allauth.account',
]
and execute "python manage.py migrate admin"
But still, I can not create django_admin_log table.
PostgreSQL version is 12.6
I just mentioned the above settings in this question but still if more code is required then tell me I'll update my question with that information. Thank you
When I try and login to my Django app, I am given this error when logging in on localhost
ImportError: No module named 'allauth.account'
But when logging in on the live app (Heroku), there is no error. Any thoughts? It makes it frustrating when I have to push the site for every small change I make on the portion of the site that you have to login to.
settings.py
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sites',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'allauth',
# 'allauth.account', Does not work when running the app
#My apps#
'home',
'projects',
'accounts',
'storages',
)
Project Structure
myproject
---accounts
---__init___.py
---views.py
---myproject
---__init___.py
---settings.py
I am getting a traceback identical to the one at this link, http://pastebin.com/Bq1Q0ert, whenever I run my project and visit it at any url.
I had resolved this issue previously by having the project serve at 0.0.0.0:8000, but now this seems to not be working either.
I am running django 1.4 and have under INSTALLED_APPS:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admindocs',
'django.contrib.humanize',
'django.contrib.webdesign',
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'apps.pages',
'apps.news',
'south',
'translatable',
'easy_thumbnails',
'debug_toolbar',
'tinymce',
'rosetta',
'django_extensions',
'sorl.thumbnail',
'vendor.filebrowser',
'vendor.countries')..
UPDATE:
I have found that django.conf.settings.INSTALLED_APPS does not contain what is in settings.INSTALLED_APPS.
I have resolved this issue by adding this code to settings_local;
from settings import *
This does not cause any cyclic imports.