Trying to follow the examples for book Django 5 By Example, 5th Edition.
One of the topis is use django-taggit. Found it is not working. When I tried to execute from django.contrib.contenttypes.models import ContentType getting some errors
from django.contrib.contenttypes.models import ContentType
Traceback (most recent call last):
File “”, line 1, in
from django.contrib.contenttypes.models import ContentType
File “c:\app\tools\python\python313\lib\site-packages\django\contrib\contenttypes\models.py”, line 134, in
class ContentType(models.Model):
…<53 lines>…
return (self.app_label, self.model)
File “c:\app\tools\python\python313\lib\site-packages\django\db\models\base.py”, line 131, in new
app_config = apps.get_containing_app_config(module)
File “c:\app\tools\python\python313\lib\site-packages\django\apps\registry.py”, line 260, in get_containing_app_config
self.check_apps_ready()
~~~~~~~~~~~~~~~~~~~~~^^
File “c:\app\tools\python\python313\lib\site-packages\django\apps\registry.py”, line 138, in check_apps_ready
raise AppRegistryNotReady(“Apps aren’t loaded yet.”)
django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet.
Not sure if I messed up the Python environment or something else. Just follow the steps from the book, page 107
You should fix your question to have properly formatted code blocks.
It’s hard to see the issue when your question is formatted like this.
Other than that, you didn’t post any context of how and where you used the code that’s causing the issue.
Hi, I am just trying to import this one in Python shell:
from django.contrib.contenttypes.models import ContentType
Then getting these errors:
Traceback (most recent call last):
File “”, line 1, in
from django.contrib.contenttypes.models import ContentType
File “c:\python313\lib\site-packages\django\contrib\contenttypes\models.py”, line 134, in
class ContentType(models.Model):
…<53 lines>…
return (self.app_label, self.model)
File “c:\python313\lib\site-packages\django\db\models\base.py”, line 131, in new
app_config = apps.get_containing_app_config(module)
File “c:\python313\lib\site-packages\django\apps\registry.py”, line 260, in get_containing_app_config
self.check_apps_ready()
~~~~~~~~~~~~~~~~~~~~~^^
File “c:\python313\lib\site-packages\django\apps\registry.py”, line 137, in check_apps_ready
settings.INSTALLED_APPS
File “c:\python313\lib\site-packages\django\conf_init_.py”, line 81, in getattr
self.setup(name)
~~~~~~~~~~~^^^^^^
File "c:\python313\lib\site-packages\django\conf_init.py", line 61, in _setup
raise ImproperlyConfigured(
…<4 lines>…
)
Also, when I am trying to put this entry in VSS Code, it is not recognizing django-taggit as well:
from taggit.managers import TaggableManager
Here are the versions:
Python: 3.13.2
Django: Version: 5.2
django-taggit: 5.0.1
Best Regards
Put three backticks ` on a separate line before and after your code and trace backs to format them correctly.
Hi,
Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
from django.contrib.contenttypes.models import ContentType
Traceback (most recent call last):
File “”, line 1, in
from django.contrib.contenttypes.models import ContentType
File “c:\python313\lib\site-packages\django\contrib\contenttypes\models.py”, line 134, in
class ContentType(models.Model):
…<53 lines>…
return (self.app_label, self.model)
File “c:\python313\lib\site-packages\django\db\models\base.py”, line 131, in new
app_config = apps.get_containing_app_config(module)
File “c:\python313\lib\site-packages\django\apps\registry.py”, line 260, in get_containing_app_config
self.check_apps_ready()
~~~~~~~~~~~~~~~~~~~~~^^
File “c:\python313\lib\site-packages\django\apps\registry.py”, line 137, in check_apps_ready
settings.INSTALLED_APPS
File “c:\python313\lib\site-packages\django\conf_init_.py”, line 81, in getattr
self.setup(name)
~~~~~~~~~~~^^^^^^
File "c:\python313\lib\site-packages\django\conf_init.py", line 61, in _setup
raise ImproperlyConfigured(
…<4 lines>…
)
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Best Regards
Put three backticks ` on a separate line before and after your code and trace backs to format them correctly.
So ``` followed by your code and then another three backticks on another line. Please don’t post images of your code or trace backs.
But it is not my code. They are errors coming from Python at all. I am just trying to do the import as mentioned:
from django.contrib.contenttypes.models import ContentType
All others are errors coming from Python itself. I do not know which code are you asking for.
How exactly are you running the Python shell? (Please post the complete commands you are issuing.)
Side note: For future reference, please do not post images of code or text. Copy/paste any code, error messages, etc into the body of your post, marked as preformatted text. You can do this either with using the preformatted text icon (</>
) in the editor bar, or surrounding your code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```.
Note that the lines of ``` must be lines by themselves, they must not be a part of other lines. Example:
# The previous line is ```
def function():
return
# The next line is ```
Hello all,
I recreated my venv and now I am able to install latest django.taggit in order to follow the examples in Chapter 03 of Django 5 by Examples book.
Thank you all for your support.
Best Regards