I've just started to learn about channels and asgi in django
in few tutorials that i've seen they do this to configure the asgi apllication
asgi.py
import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = ProtocolTypeRouter({
'http':get_asgi_application(),
})
settings.py
INSTALLED_APPS = [
'channels',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'chat'
]
ASGI_APPLICATION = 'config.asgi.application'
to check when i run my server it was supposed to be running on asgi/channel server like this
Starting ASGI/Channels version development server at http://127.0.0.1:8000/
but mine is still running on the default one
Starting development server at http://127.0.0.1:8000/
when i use daphne and put inside installed apps instead of channels
'daphne',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'chat'
]
it works fine
Starting ASGI/Daphne version 4.0.0 development server at http://127.0.0.1:8000/
can someone tell me what is going on here?and how exactly django works with asgi?
I'm trying to change the structure of my project. In fact, I would like to have an apps folder where I can stock all my project's apps.
In this case I making a member app into the given folder. If I try to run the project I have this error:
django.core.exceptions.ImproperlyConfigured: Cannot import 'member'. Check that 'apps.member.apps.MemberConfig.name' is correct.
In my settings.py I configured my INSTALLED_APPS as follow:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'apps.member.apps.MemberConfig',
]
Basically, I just want to have the following folder structure:
project_folder/
___ apps/
___ config/
For the rest of the settings folder here is the GIST
More information:
Django version : 1.11
Python version: 3.5.2
OS: Ubuntu 16
Change "apps.member.apps.MemberConfig" to "apps.member"
Here is my settings.
########## APP CONFIGURATION
DJANGO_APPS = (
# Default Django apps:
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Useful template tags:
# 'django.contrib.humanize',
# Admin panel and documentation:
'django.contrib.admin',
# 'django.contrib.admindocs',
)
THIRD_PARTY_APPS = (
'south',
'colorful',
#'grappelli',
'django_extensions',
#'rest_framework',
#'sorl.thumbnail',
'guardian',
'sslserver',
'djangosecure',
'django_nose',
)
# Apps specific for this project go here.
LOCAL_APPS = (
'main',
'executor',
'workshop',
'management',
)
And here is my loaded python apps:
Django < 1.7
South === 1.0
django-colorful
django-extensions == 1.5.2
django-mptt == 0.7.4
loremipsum < 1.0.4
django_debug_toolbar
werkzeug == 0.11.4
Pillow == 3.1.1
MySQL-python
xlwt
xlrd
django-guardian == 1.3.2
lxml
fabric
django-fab-deploy
django-secure === 1.0.1
django-sslserver === 0.15
python-ldap === 2.4.19
django_auth_ldap
html2text
htmlentities
openpyxl
raven
colorful
ipython == 4.1.1
django-nose
newrelic
I have done none code changes and now I can't create or update instances. I will get this error message in server:
File "/srv/www/lohja/targetor/env/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 129, in get_user_model
[targetor_upgrade#targetorpro.fi] out:
raise ImproperlyConfigured("AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL)
[targetor_upgrade#targetorpro.fi] out:
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'executor.ExecutorUser' that has not been installed
[targetor_upgrade#targetorpro.fi] out:
Fatal error: run() received nonzero return code 1 while executing!
Requested: /srv/www/lohja/targetor/env/bin/python /srv/www/lohja/targetor/manage.py migrate --fake --no-initial-data guardian --settings=settings.local_setti$
Executed: /bin/bash -l -c "cd /srv/www/lohja/targetor/env/bin/ && . /srv/www/lohja/targetor/env/bin/activate && /srv/www/lohja/targetor/env/bin/python /srv/w$
Aborting.
I guess there are some changes in python apps which will do this error. But I can't find which version of certain apps I have to use. I had have already this kind of problem but managed to solve those. Now, I can't find the reason... Does anyone else fix this issue?
Could be due to missing django make sure all the requirement have been install. If you are using VirtualEnv make sure you activate prior to starting your server using manage.py
I am trying to use admin.LogEntry objects during a datamigration on Django 1.7
The 'django.contrib.admin' app is listed on INSTALLED_APPS.
On the shell, it works:
>>> from django.apps import apps
>>> apps.get_model('admin', 'LogEntry')
django.contrib.admin.models.LogEntry
But during the migration, it fails:
def do_it(apps, schema_editor):
LogEntry = apps.get_model('admin', 'LogEntry')
Fails like this:
django-admin migrate
(...)
LookupError: No installed app with label 'admin'.
Using a debugger, I got that the 'admin' is not installed:
ipdb> apps.get_apps()
[]
ipdb> apps.all_models.keys()
['website', 'google', 'allauth', 'twitter', 'busca', 'conteudo', 'django_mobile', 'django_filters', 'videocenter', 'tinymce', 'oferta', 'programacaotv', 'contenttypes', 'suit', 'haystack', 'destaque', 'filer', 'galeria', 'auth', 'facebook', 'paintstore', 'critica', 'disqus', 'fichas', 'omeletop', 'autocomplete_light', 'modelsv1', 'temas', 'django_extensions', 'adv_cache_tag', 'taggit', 'social', 'personalidade']
WHY??
The Django doc makes it clear:
When writing a RunPython function that uses models from apps other than the one in which the migration is located, the migration’s dependencies attribute should include the latest migration of each app that is involved, otherwise you may get an error similar to: LookupError: No installed app with label 'myappname' when you try to retrieve the model in the RunPython function using apps.get_model().
Code example:
# Imports are omitted for the sake of brevity
def move_m1(apps, schema_editor):
LogEntry = apps.get('admin.logentry')
# Other business logic here ...
class Migration(migrations.Migration):
dependencies = [
('app1', '0001_initial'),
# Below is the manually added dependency, so as to retrieve models
# of 'django.contrib.admin' app with apps.get_model() in move_m1().
#
# Currently this is for Django 1.11. You need to look into
# 'django/contrib/admin/migrations' directory to find out which is
# the latest migration for other version of Django.
('admin', '0002_logentry_remove_auto_add'),
]
operations = [
migrations.RunPython(move_m1),
]
Just check your setting.py in the installed apps section and make sure that you have added your app there :
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'--- you need to add your app here ---',
]
I don't know the exact cause for this. Will have to dig into the source code. but for now a workaround is add
('admin', 'name_of_last_migration_in_admin_app') to the dependencies and the migrations shall go alright.
I got the same error (but unrelated to the issue mentioned in question). I was using mysql db but there were no mysql client.
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
# other details like name, user, host
}
}
I installed mysqlclient (In ubuntu & Python3):
sudo apt-get install libmysqlclient-dev
sudo apt-get install python3-dev
pip install mysqlclient
I was getting a similar error and I am a total novice programmer. One solution that worked for me was installing sqlparse. Try
pip install sqlparse
I also had this same error of "no installed app label 'admin' ". I was able to solve it by running the pip install sqlparse command
Try looking further up your stack trace too. I got this error due to a misconfigured logger but I had to look further up the trace to find this issue!
In my case I had misnamed my environment variable DJANGO_LOG_LEVL as DEGUB instead of DEBUG (note the misspelling) and that caused the error.
In my case, app name wasn't added to the settings.py file under "INSTALLED APPS" dictionary
On the Installed Applications, make sure you have the app. For instance, I have Polls under the settings.py file.
Application definition
INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
For me it shows
raise LookupError(message)
LookupError: No installed app with label 'admin'.
and I solve it by pip installing every requirements manually I m using ubuntu 16.04
For my case the LookupError was occuring because I had altered the models and added 'related_name' but had not run makemigrations and migrate.
I got the error when I used 'required=False' in my model like this:
slug = models.SlugField(required=False)
I changed it to: slug = models.SlugField(blank=True,null=True) and the error disappeared
I also got this error after changing database from sqlite to postgresql and by installing
psycog2 (which is used to connect django to postgre database) my error has gone.
pip install psycog2
Had troubles with this too, all I did was upgrade pip and it seemed to fix itself tried installing other dependencies but turned out I already had them all so if you are in the same position try upgrading your pip!
The same thing also happened to me, but in my case the INSTALLED_APPS variable had been overwritten a few lines below in this file in the settings.py file.
create a virtual environment and install all the required dependency
or packages in virtual environment
I had faced the same problem. But after some analysis, I found that I didn't put the newly created app name into my setting.py.when I placed it then it worked.
Your setting.py will look like this one :
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
You need to do makemigrations n migrate after you will not find this type of error
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 *).