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 *).
Related
I am facing this problem with migrating in Django admin after I updated the app name 'rest_framework.authtoken' in django project settings.
It gives me error The model TokenProxy is already registered in app 'authtoken'.
I know I should have added this and migrate before creating super user but now I have already created the project and migrated lots of models and there is a data in it. Can help me how I can resolve this problem.
I also tried to undo migrations with command python manage.py migrate books but it again does not recognize the word books.
Please help me with this.
Here is my apps in settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts',
'traderskamp_app',
'rest_framework.authtoken',
'rest_framework',
'corsheaders',
]
Here is the exact error:
File "C:\Python39\lib\site-packages\rest_framework\authtoken\admin.py", line 51, in
admin.site.register(TokenProxy, TokenAdmin)
File "C:\Users\Anwar\AppData\Roaming\Python\Python39\site-packages\django\contrib\admin\sites.py", line 126, in register
raise AlreadyRegistered(msg)
django.contrib.admin.sites.AlreadyRegistered: The model TokenProxy is already registered in app 'authtoken'.
might be a bit late but I would search your project for this.
admin.site.register(TokenProxy)
you are likely registering TokenProxy somewhere in your code and that is causing a conflict with authtoken
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
I'm currently beginning a project in Django 1.10, trying to use the included flat pages application. After installing the apps within my (base) settings file:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'first_app']
SITE_ID = 1 # for use with 'django.contrib.sites'
Yet when I run python manage.py migrate, the console returns the following error:
RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an
explicit app_label and isn't in an application in INSTALLED_APPS.
Can someone explain to me what is causing this error, when I clearly declared the app in my 'INSTALLED_APPS' list?
Thanks in advance for any advice!
NOTE: It may be worth noting that I'm using multiple settings files, but this code is within the base settings file (the other files change small things such as the DEBUG variable), but i've had no problems running the server or any other errors.
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.
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.