Import errors in django-cms - python

I am a newbie to django and after going through some django tutorial i have started using django-cms(I had a requirement to develop a cms site with django-cms).
I have edited the settings file and added all the middlewares,apps that are necessary for cms, so everything is going fine and started developing html templates, but sometimes after i restarting the server and getting the below weird errors
Error_1
Django Version: 1.4.3
Exception Type: ImportError
Exception Value:
cannot import name plugin_pool
Exception Location: /usr/lib/python2.7/site-packages/cms/admin/__init__.py in <module>, line 7
Python Executable: /usr/bin/python
Error_2
Django Version: 1.4.3
Exception Value: Reverse for 'pages-root' with arguments '()' and keyword arguments '{}' not found
Exception Location: /usr/lib/python2.7/site-packages/cms/models/__init__.py in new_reverse, line 67
Python Executable: /usr/bin/python
................
These are the two errors i am facing sometimes and don't know why they are encountered because they are appearing suddenly, can i know how to avoid these errors
some of the settings are below
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware', #CMS
'cms.middleware.page.CurrentPageMiddleware', #CMS
'cms.middleware.user.CurrentUserMiddleware', #CMS
'cms.middleware.toolbar.ToolbarMiddleware', #CMS
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'cms',
'mptt',
'menus',
'south',
'sekizai',
'reversion',
'cms.plugins.text',
'filer',
'easy_thumbnails',
'cmsplugin_filer_file',
'cmsplugin_filer_image',
'cmsplugin_filer_teaser',
'cms.plugins.link',
'cms_themes',
)

Using Django 1.4.3 I have had the same problem with this error:
ImportError at / - cannot import name plugin_pool
after research i have found that simply by updating my django to version 1.4.5
my plugin_pool import error has gone away.

Related

Django - ModuleNotFoundError: No module named 'alluth'

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

Django ImportError at /admin/ cannot import name 'Session'

I get this message in Django after running runserver:
ImportError at /admin/login/ cannot import name 'Session' Request
Method: POST Request
URL: http://127.0.0.1:8000/admin/login/?next=/admin/ Django
Version: 2.0.5 Exception Type: ImportError Exception Value: cannot
import name 'Session' Exception
Location: C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\site-packages\django\contrib\sessions\backends\db.py
in get_model_class, line 23 Python
Executable: C:\HOMEWARE\Anaconda3-Windows-x86_64\python.exe Python
Version: 3.6.4
This is part of my code in settings.py:
# Application definition
INSTALLED_APPS = [
'AppFinal.apps.AppfinalConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#'AppFinal'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'ProjetFinal.urls'
I've checked everything, but it seems alright, does anyone knows how to handle this kind of error?
thanks

No 'Access-Control-Allow-Origin' header is present on the requested resource.

I am using ajax to call the following url:
"https://www.bittrex.com/api/v1.1/public/getticker?market=usdt-btc"
I am getting the following error:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
I have installed django-cors-headers and my settings.py looks like this:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'crispy_forms',
# The following apps are required:
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = (
'http://127.0.0.1:8000',
)
Why am I still getting the error?
** I have read all the other answers related to this but they have not helped me. I have used the chrome plugin too and it does work with it but I want a solution without it **
Django Version = 1.8
The configuration looks fine and according to the documentation. I just compared it to my configuration and it's almost the same. Since I use my API for only one website, I have it configured in my CORS_ORIGIN_WHITELIST, you can try this also to see if it responds.
Also, try removing all python cache files and restart the application server, maybe the setting where not loaded.
It is not your app issue i.e. django issue as CORS is a http header which let's a user agent gain permission to a resource which is on a different domain as that of yours. It is a browser issue, hence adding CORS application in django will have no effect.
More information here
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
Try adding crossDomain: true in the ajax request

Django allauth error - ImproperlyConfigured - "No module named messagesallauth.account.context_processors"

I get the following error after the first steps of django-allauth installation.
ImproperlyConfigured at /admin/
Error importing module django.contrib.messages.context_processors.messagesallauth.account.context_processors: "No module named messagesallauth.account.context_processors"
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.6.6
Exception Type: ImproperlyConfigured
Exception Value:
Error importing module django.contrib.messages.context_processors.messagesallauth.account.context_processors: "No module named messagesallauth.account.context_processors"
Exception Location: /home/miguelfg/workspace/python_environments/tdcp_observatorio/local/lib/python2.7/site-packages/django/utils/importlib.py in import_module, line 40
Python Executable: /home/miguelfg/workspace/python_environments/tdcp_observatorio/bin/python2.7
Python Version: 2.7.3
Python Path:
['/home/miguelfg/workspace/projects/python/tdcp_observatorio',
'/home/miguelfg/workspace/projects/python/tdcp_observatorio',
'/home/miguelfg/workspace/python_environments/tdcp_observatorio/lib/python2.7',
'/home/miguelfg/workspace/python_environments/tdcp_observatorio/lib/python2.7/plat-linux2',
'/home/miguelfg/workspace/python_environments/tdcp_observatorio/lib/python2.7/lib-tk',
'/home/miguelfg/workspace/python_environments/tdcp_observatorio/lib/python2.7/lib-old',
'/home/miguelfg/workspace/python_environments/tdcp_observatorio/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/home/miguelfg/workspace/python_environments/tdcp_observatorio/local/lib/python2.7/site-packages',
'/home/miguelfg/workspace/python_environments/tdcp_observatorio/local/lib/python2.7/site-packages/PIL']
Server time: Wed, 3 Sep 2014 12:29:34 +0200
I have gone through all installation steps, including syncdb or migrate commands, until login the django admin interface and add a Site and Social Apps.
Here parts of my settings file:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages'
# allauth specific context processors
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'custom_middleware.memory.MemoryUsageMiddleware',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
...
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.google',
)
SITE_ID = 1
...
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
I'm using allauth in another project and I've never got this. Any help is very welcome :-)

Django settings.py not being detected

I'm pretty new to Django and I'm having some difficulty getting my settings.py to load properly. I'm getting the following error:
ImproperlyConfigured at /admin
Put 'django.contrib.admin' in your INSTALLED_APPS setting in order to
use the admin application.
However, my settings.py INSTALLED_APPS looks as follows:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'squaredcrm' )
Looking through the error log, I've noticed its not picking up any of my changes to installed apps:
Django Version: 1.4.3 Python Version: 2.7.3 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sites',
'django.contrib.messages', 'django.contrib.staticfiles') Installed
Middleware: ('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
I cannot figure this out for the life of me. Any other changes seem to be working, but this field will not update. Any ideas?
I know it's a silly question, but did you restart your server after making the changes?
By default, production (by which I mean Apache-based, and perhaps other) instances of Django do not auto-reload on changes. The Django development server will auto-reload, as long as you don't specifically tell it not to.
You have to restart (or stop and then start) an Apache-based Django for it to see the file changes.
Important tip: do not run a production site off of the development server. It is slow, slow, slow, and probably insecure in ways I don't know about.
If other changes are picked up, this is probably because INSTALLED_APPS is being redefined somewhere in your settings.py file.
This could be:
At a subsequent line.
In an import (likely a from x import *).

Categories