I am learning to use Django, and when trying to install Crispy Forms and running 'makemigrations,' I encounter the following error:
Traceback (most recent call last):
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/db/models/options.py", line 275, in _get_default_pk_class
pk_class = import_string(pk_class_path)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/utils/module_loading.py", line 30, in import_string
return cached_import(module_path, class_name)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/utils/module_loading.py", line 15, in cached_import
module = import_module(module_path)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django.Falsedb'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/javier/Desktop/pd110/src/manage.py", line 22, in <module>
main()
File "/home/javier/Desktop/pd110/src/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/core/management/commands/makemigrations.py", line 156, in handle
loader.check_consistent_history(connection)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/db/migrations/loader.py", line 313, in check_consistent_history
applied = recorder.applied_migrations()
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/db/migrations/recorder.py", line 81, in applied_migrations
if self.has_table():
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/db/migrations/recorder.py", line 59, in has_table
return self.Migration._meta.db_table in tables
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/utils/functional.py", line 71, in __get__
return self.fget(cls)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/db/migrations/recorder.py", line 32, in Migration
class Migration(models.Model):
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/db/models/base.py", line 365, in __new__
new_class._prepare()
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/db/models/base.py", line 378, in _prepare
opts._prepare(cls)
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/db/models/options.py", line 329, in _prepare
pk_class = self._get_default_pk_class()
File "/home/javier/Desktop/pd110/lib/python3.10/site-packages/django/db/models/options.py", line 281, in _get_default_pk_class
raise ImproperlyConfigured(msg) from e
django.core.exceptions.ImproperlyConfigured: DEFAULT_AUTO_FIELD refers to the module 'django.Falsedb.models.BigAutoField' that could not be imported.
I've performed migrations before without any issues. In my 'settings.py,' I have the following in the 'installed apps':
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
'boletin',
]
boletin is my app name My project tree structure is the following one: enter image description here
I tried uninstalling and reinstalling Django 4.2.7 and Crispy Forms in my virtual environment, but it didn't work. I would appreciate it if someone could provide me with some assistance because I'm just starting with Django and I haven't mastered it yet. Thank you, and sorry for my poor English
I suspect that django.db.models.BigAutoField
has become django.Falsedb.models.BigAutoField
by mistake somewhere in your project.
Have a look in your settings.py
file and make sure that DEFAULT_AUTO_FIELD
option is set correctly,
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
The same setting is also set in the apps.py
file for each of your installed apps. For example
from django.apps import AppConfig
class BooksConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "books"
Failing that do a global search in your code base for Falsedb
.