# Unable to install Django-Debug-Toolbar

**URL:** <https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182>\
**Category:** Django\
**Created:** [July 17, 2021, 9:00pm UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182 "2021-07-17T21:00:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![webbografico](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/webbografico/32/1955_2.png) [@webbografico](https://forum.codewithmosh.com/u/webbografico)\
**Post date:** [July 17, 2021, 9:00pm UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182/1 "2021-07-17T21:00:16Z")

</div>

Hi there, I’m following the instruction in Mosh video about installing django-debug-toolbar on video 12 of Fundamentals in the ultimate django series and getting this error when loading [http://127.0.0.1:8000/playground/hello/](http://127.0.0.1:8000/playground/hello/) after following Mosh’s instruction on installing the toolbar:

# RuntimeError at /playground/hello/

Model class django.contrib.sessions.models.Session doesn’t declare an explicit app\_label and isn’t in an application in INSTALLED\_APPS.

| Request Method: | GET |
| --- | --- |
| Request URL: | [http://127.0.0.1:8000/playground/hello/](http://127.0.0.1:8000/playground/hello/) |
| Django Version: | 3.2.5 |
| Exception Type: | RuntimeError |
| Exception Value: | Model class django.contrib.sessions.models.Session doesn’t declare an explicit app\_label and isn’t in an application in INSTALLED\_APPS. |
| Exception Location: | /Users/enricobonardi/.virtualenvs/storefront-cv1BudZW/lib/python3.9/site-packages/django/db/models/base.py, line 113, in **new** |
| Python Executable: | /Users/enricobonardi/.virtualenvs/storefront-cv1BudZW/bin/python3 |
| Python Version: | 3.9.5 |
| Python Path: | [‘/Users/enricobonardi/CODING/ULTIMATE DJANGO PT.1/storefront’, ‘/Library/Frameworks/Python.framework/Versions/3.9/lib/python39.zip’, ‘/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9’, ‘/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload’, ‘/Users/enricobonardi/.virtualenvs/storefront-cv1BudZW/lib/python3.9/site-packages’] |

any ideas where’s my mistake?

---

<div class="post-metadata">

**Author:** ![webbografico](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/webbografico/32/1955_2.png) [@webbografico](https://forum.codewithmosh.com/u/webbografico)\
**Post date:** [July 18, 2021, 7:23am UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182/2 "2021-07-18T07:23:10Z")

</div>

Solved… in a previous video Mosh talk about removing ‘django.contrib.sessions’ from INSTALLED\_APPS because is legacy… but adding again solved my problem.

---

<div class="post-metadata">

**Author:** ![DzTech](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@DzTech](https://forum.codewithmosh.com/u/DzTech)\
**Post date:** [July 20, 2021, 5:52pm UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182/3 "2021-07-20T17:52:53Z")

</div>

Hi  
I am running thru the same issue , and removing ‘django.contrib.sessions’ didn’t solve the problem  
it look likes the import is not working

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/0/04bc0211e241b803c03b06801e1e28f33d49a3b9.png)

Environment:

Request Method: GET  
Request URL: [http://127.0.0.1:8000/](http://127.0.0.1:8000/)

Django Version: 3.2.5  
Python Version: 3.9.6  
Installed Applications:  
[‘django.contrib.admin’,  
‘django.contrib.auth’,  
‘django.contrib.contenttypes’,  
‘django.contrib.messages’,  
‘django.contrib.staticfiles’,  
‘playground’,  
‘debug\_toolbar’]  
Installed Middleware:  
[‘debug\_toolbar.middleware.DebugToolbarMiddleware’,  
‘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’]

Traceback (most recent call last):  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\base.py”, line 233, in \_get\_session  
return self.\_session\_cache

During handling of the above exception (‘SessionStore’ object has no attribute ‘\_session\_cache’), another exception occurred:  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\db.py”, line 32, in \_get\_session\_from\_db  
return self.model.objects.get(  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\utils\functional.py”, line 48, in **get**  
res = instance. **dict** [self.name] = self.func(instance)  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\db.py”, line 28, in model  
return self.get\_model\_class()  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\db.py”, line 23, in get\_model\_class  
from django.contrib.sessions.models import Session  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\models.py”, line 10, in   
class Session(AbstractBaseSession):  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\db\models\base.py”, line 113, in **new**  
raise RuntimeError(

During handling of the above exception (Model class django.contrib.sessions.models.Session doesn’t declare an explicit app\_label and isn’t in an application in INSTALLED\_APPS.), another exception occurred:  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\core\handlers\exception.py”, line 47, in inner  
response = get\_response(request)  
File “c:\users\the\_m.virtualenvs\storefront-ynfqwea1\src\django-debug-toolbar\debug\_toolbar\middleware.py”, line 67, in **call**  
panel.generate\_stats(request, response)  
File “c:\users\the\_m.virtualenvs\storefront-ynfqwea1\src\django-debug-toolbar\debug\_toolbar\panels\request.py”, line 66, in generate\_stats  
for k in sorted(request.session.keys())  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\base.py”, line 169, in keys  
return self.\_session.keys()  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\base.py”, line 238, in \_get\_session  
self.\_session\_cache = self.load()  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\db.py”, line 43, in load  
s = self.\_get\_session\_from\_db()  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\db.py”, line 36, in \_get\_session\_from\_db  
except (self.model.DoesNotExist, SuspiciousOperation) as e:  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\utils\functional.py”, line 48, in **get**  
res = instance. **dict** [self.name] = self.func(instance)  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\db.py”, line 28, in model  
return self.get\_model\_class()  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\backends\db.py”, line 23, in get\_model\_class  
from django.contrib.sessions.models import Session  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\contrib\sessions\models.py”, line 10, in   
class Session(AbstractBaseSession):  
File “C:\Users\the\_m.virtualenvs\storefront-ynfQWea1\lib\site-packages\django\db\models\base.py”, line 113, in **new**  
raise RuntimeError(

Exception Type: RuntimeError at /  
Exception Value: Model class django.contrib.sessions.models.Session doesn’t declare an explicit app\_label and isn’t in an application in INSTALLED\_APPS.

help please !!!

---

<div class="post-metadata">

**Author:** ![webbografico](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/webbografico/32/1955_2.png) [@webbografico](https://forum.codewithmosh.com/u/webbografico)\
**Post date:** [July 22, 2021, 8:12am UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182/4 "2021-07-22T08:12:36Z")

</div>

I solved my problem by putting back ‘django.contrib.sessions’ in INSTALLED\_APPS (removed as stated by Mosh in a previous video) and everything works after that. It seems you get the same error so check the presence of ‘django.contrib.sessions’ in settings.py. If you get the error you can try the solution found here:

[https://stackoverflow.com/questions/35388637/runtimeerror-model-class-django-contrib-sites-models-site-doesnt-declare-an-ex](https://stackoverflow.com/questions/35388637/runtimeerror-model-class-django-contrib-sites-models-site-doesnt-declare-an-ex)

---

<div class="post-metadata">

**Author:** ![Jorgealbarracin00](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jorgealbarracin00/32/2068_2.png) [@Jorgealbarracin00](https://forum.codewithmosh.com/u/Jorgealbarracin00)\
**Post date:** [August 5, 2021, 3:19pm UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182/5 "2021-08-05T15:19:43Z")

</div>

> [@DzTech](#):
>
> removing ‘django.contrib.sessions’

The same happened to me. I fixed the : removing ‘django.contrib.sessions’.  
I continued to have an error message.

I run: python manage.py migrate  
and it is working now.

Hope this works for you.

---

<div class="post-metadata">

**Author:** ![Mrfinesse47](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mrfinesse47](https://forum.codewithmosh.com/u/Mrfinesse47)\
**Post date:** [January 22, 2023, 5:35am UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182/6 "2023-01-22T05:35:56Z")

</div>

I can confirm that putting back the one line of code and running migrate solved the issue for me as well.

---

<div class="post-metadata">

**Author:** ![Costas\_zeb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/costas_zeb/32/7352_2.png) [@Costas\_zeb](https://forum.codewithmosh.com/u/Costas_zeb)\
**Post date:** [November 22, 2023, 10:03am UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182/7 "2023-11-22T10:03:48Z")

</div>

Hello everyone, adding django.contrib.sessions, didn’t solve it for me  
Actually when I add it, I get  
`TypeError: 'module' object is not callable`

---

<div class="post-metadata">

**Author:** ![jendives](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jendives](https://forum.codewithmosh.com/u/jendives)\
**Post date:** [March 21, 2024, 7:33am UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182/8 "2024-03-21T07:33:04Z")

</div>

It worked for me. Thanks.  
Mosh should update that video where he tells us to remove that culprit line. Or explain to us what to do if we keep it removed.

The error message (shown on top of this thread) is actually telling us that it is missing that session app and because of that its related model class can’t do its job (declare):

“Model class django.contrib.sessions.models.Session doesn’t declare an explicit app\_label and isn’t in an application in INSTALLED\_APPS.”

That tells me in a vague way what happened but it does not explain it to me.  
Class are basically objects, so declare is probably a method of that session class. It’s worth checking the models.py file to understand it further.

---

<div class="post-metadata">

**Author:** ![KoB8096](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@KoB8096](https://forum.codewithmosh.com/u/KoB8096)\
**Post date:** [June 23, 2024, 11:56am UTC](https://forum.codewithmosh.com/t/unable-to-install-django-debug-toolbar/6182/9 "2024-06-23T11:56:27Z")

</div>

Perfect! Thank you for the help.
