I am learning Django but have encountered a problem while adding apps to Installed apps in settings.py
I added 'polls' app
INSTALLED_APPS = [
'polls.apps.PollsConfig'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
but an error has occurred which says
ImportError: No module named 'polls.apps.PollsConfigdjango'; 'polls.apps' is not a package
when I write only 'polls' instead of 'polls.apps.PollsConfig'
the following error occurs `ImportError: No module named 'pollsdjango'
the name of app I am trying to import is 'polls'
You are missing a comma after PollsConfig'
Try this
INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
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
So following the current Django-allauth documentation, I keep getting this minor syntax error when I thought I followed the documentation to every last detail.
Terminal error after running: ./manage.py migrate
/settings.py", line 43
'django.contrib.auth',
^
SyntaxError: invalid syntax
My settings.py file: Was I not supposed to keep the default apps above the allauth section?
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
...
# The following apps are required:
'django.contrib.auth',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
# ... include the providers you want to enable:
'allauth.socialaccount.providers.amazon',
'allauth.socialaccount.providers.angellist',
'allauth.socialaccount.providers.asana',
The error is coming because 'django.contrib.auth' is repeating
'django.contrib.admin',
'django.contrib.auth',
and again
# The following apps are required:
'django.contrib.auth',
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.