ModuleNotFoundError: No module named 'users' from dj-rest-auth - python-3.x
I am trying to run celery on a Django application that has dj-rest-auth already configured but, I get the following error when I run - "celery -A config worker -l info" but, it works perfectly fine without errors when I do "python manage.py runserver".
The application has several apps under the folder /apps and within the settings.py, it is imported as "apps.<app_name>". It does have an app called "users" so, it's imported as "apps.users".
Traceback (most recent call last):
File "/usr/local/bin/celery", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/celery/__main__.py", line 15, in main
sys.exit(_main())
File "/usr/local/lib/python3.10/site-packages/celery/bin/celery.py", line 213, in main
return celery(auto_envvar_prefix="CELERY")
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/bin/base.py", line 134, in caller
return f(ctx, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/bin/worker.py", line 343, in worker
worker = app.Worker(
File "/usr/local/lib/python3.10/site-packages/celery/worker/worker.py", line 94, in __init__
self.app.loader.init_worker()
File "/usr/local/lib/python3.10/site-packages/celery/loaders/base.py", line 111, in init_worker
self.import_default_modules()
File "/usr/local/lib/python3.10/site-packages/celery/loaders/base.py", line 105, in import_default_modules
raise response
File "/usr/local/lib/python3.10/site-packages/celery/utils/dispatch/signal.py", line 276, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python3.10/site-packages/celery/fixups/django.py", line 82, in on_import_modules
self.worker_fixup.validate_models()
File "/usr/local/lib/python3.10/site-packages/celery/fixups/django.py", line 121, in validate_models
run_checks()
File "/usr/local/lib/python3.10/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/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 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/app/config/urls.py", line 13, in <module>
path("api/v1/auth/", include("dj_rest_auth.urls")),
File "/usr/local/lib/python3.10/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/local/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 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/urls.py", line 4, in <module>
from dj_rest_auth.views import (
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/views.py", line 16, in <module>
from .app_settings import (
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/app_settings.py", line 35, in <module>
UserDetailsSerializer = import_callable(serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer))
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/utils.py", line 12, in import_callable
return getattr(import_module(package), attr)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'users'
root#1a45d3d56ced:/app# celery -A config worker -l info
DEBUG 2021-12-09 11:36:44,651 base 132 140186677212992 Configuring Raven for host: None
INFO 2021-12-09 11:36:44,652 base 132 140186677212992 Raven is not configured (logging is disabled). Please see the documentation for more information.
Traceback (most recent call last):
File "/usr/local/bin/celery", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/celery/__main__.py", line 15, in main
sys.exit(_main())
File "/usr/local/lib/python3.10/site-packages/celery/bin/celery.py", line 213, in main
return celery(auto_envvar_prefix="CELERY")
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/bin/base.py", line 134, in caller
return f(ctx, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/bin/worker.py", line 343, in worker
worker = app.Worker(
File "/usr/local/lib/python3.10/site-packages/celery/worker/worker.py", line 94, in __init__
self.app.loader.init_worker()
File "/usr/local/lib/python3.10/site-packages/celery/loaders/base.py", line 111, in init_worker
self.import_default_modules()
File "/usr/local/lib/python3.10/site-packages/celery/loaders/base.py", line 105, in import_default_modules
raise response
File "/usr/local/lib/python3.10/site-packages/celery/utils/dispatch/signal.py", line 276, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python3.10/site-packages/celery/fixups/django.py", line 82, in on_import_modules
self.worker_fixup.validate_models()
File "/usr/local/lib/python3.10/site-packages/celery/fixups/django.py", line 121, in validate_models
run_checks()
File "/usr/local/lib/python3.10/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/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 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/app/config/urls.py", line 13, in <module>
path("api/v1/auth/", include("dj_rest_auth.urls")),
File "/usr/local/lib/python3.10/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/local/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 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/urls.py", line 4, in <module>
from dj_rest_auth.views import (
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/views.py", line 16, in <module>
from .app_settings import (
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/app_settings.py", line 35, in <module>
UserDetailsSerializer = import_callable(serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer))
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/utils.py", line 12, in import_callable
return getattr(import_module(package), attr)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'users'
We faced the same problem. The imports in this case include the module specification strings from settings.py, not just the import statements at the top of the modules. In our case this was the fix
REST_AUTH_SERIALIZERS = {
- "LOGIN_SERIALIZER": "users.api.serializers.LoginSerializer",
+ "LOGIN_SERIALIZER": "<app_name>.users.api.serializers.LoginSerializer",
}
Related
Django or python version issue: ModuleNotFoundError: No module named 'database'
when i try to start my Django project i get this error which i am unable to solve: ModuleNotFoundError: No module named 'database' The error stack: Traceback (most recent call last): File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv self.execute(*args, **cmd_options) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/core/management/base.py", line 455, in execute self.check() File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/core/management/base.py", line 487, in check all_issues = checks.run_checks( File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/core/checks/registry.py", line 88, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/core/checks/caches.py", line 17, in check_default_cache_is_configured if DEFAULT_CACHE_ALIAS not in settings.CACHES: File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 87, in __getattr__ self._setup(name) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 74, in _setup self._wrapped = Settings(settings_module) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 183, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) 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 'database' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/olw/candidatis/database-rest/manage.py", line 22, in <module> main() File "/home/olw/candidatis/database-rest/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/core/management/base.py", line 427, in run_from_argv connections.close_all() File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/db/utils.py", line 212, in close_all for alias in self: File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/utils/connection.py", line 73, in __iter__ return iter(self.settings) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/utils/functional.py", line 49, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/utils/connection.py", line 45, in settings self._settings = self.configure_settings(self._settings) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/db/utils.py", line 148, in configure_settings databases = super().configure_settings(databases) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/utils/connection.py", line 50, in configure_settings settings = getattr(django_settings, self.settings_name) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 87, in __getattr__ self._setup(name) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 74, in _setup self._wrapped = Settings(settings_module) File "/home/olw/candidatis/database-rest/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 183, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) 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 'database' I already tried to install the databases package (This is the recommended answer you almost find anywhere) Trying to make sense out of the stack trace it seems that python itself cannot import this module (So there is no issue in my code or something...). My installed packages: The python version i am using is Python 3.10.5 Anybody any idea ? UPDATE APPS LIST Here is my installed apps list -> INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "django.contrib.admindocs.urls", "rest", "rest_framework", "custom_db_logger", ]
Why does QtConsole error out when I try to convert it to bundle in pyinstaller?
My qtconsole code is this: import sys from qtpy import QtWidgets from qtconsole.rich_jupyter_widget import RichJupyterWidget from qtconsole.manager import QtKernelManager # The ID of an installed kernel, e.g. 'bash' or 'ir'. USE_KERNEL = 'python3' def make_jupyter_widget_with_kernel(): """Start a kernel, connect to it, and create a RichJupyterWidget to use it """ kernel_manager = QtKernelManager(kernel_name=USE_KERNEL) kernel_manager.start_kernel() kernel_client = kernel_manager.client() kernel_client.start_channels() jupyter_widget = RichJupyterWidget() jupyter_widget.kernel_manager = kernel_manager jupyter_widget.kernel_client = kernel_client return jupyter_widget class MainWindow(QtWidgets.QMainWindow): """A window that contains a single Qt console.""" def __init__(self): super().__init__() self.jupyter_widget = make_jupyter_widget_with_kernel() self.setCentralWidget(self.jupyter_widget) def shutdown_kernel(self): print('Shutting down kernel...') self.jupyter_widget.kernel_client.stop_channels() self.jupyter_widget.kernel_manager.shutdown_kernel() if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) window = MainWindow() window.show() app.aboutToQuit.connect(window.shutdown_kernel) sys.exit(app.exec_()) it successfully compiles when I run it but when I click on the finished pyinstaller (pyinstaller --onefile main.py or pyinstaller --windowed --onedir Yuro.py) bundle, this qtconsole errors out with message: File "main.py", line 38, in <module> File "main.py", line 28, in __init__ File "main.py", line 14, in make_jupyter_widget_with_kernel File "jupyter_client/utils.py", line 26, in wrapped File "jupyter_client/utils.py", line 23, in wrapped File "nest_asyncio.py", line 70, in run_until_complete File "asyncio/futures.py", line 201, in result File "asyncio/tasks.py", line 256, in __step File "jupyter_client/manager.py", line 362, in _async_start_kernel File "jupyter_client/manager.py", line 347, in _async_start_kernel File "jupyter_client/utils.py", line 26, in wrapped File "jupyter_client/utils.py", line 23, in wrapped File "nest_asyncio.py", line 70, in run_until_complete File "asyncio/futures.py", line 201, in result File "asyncio/tasks.py", line 256, in __step File "jupyter_client/manager.py", line 308, in _async_pre_start_kernel File "jupyter_client/manager.py", line 138, in kernel_spec File "jupyter_client/kernelspec.py", line 294, in get_kernel_spec File "jupyter_client/kernelspec.py", line 247, in _get_kernel_spec_by_name File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module File "ipykernel/kernelspec.py", line 16, in <module> File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module File "ipykernel/ipkernel.py", line 38, in <module> File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module File "ipykernel/debugger.py", line 20, in <module> File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module File "debugpy/server/__init__.py", line 9, in <module> File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module File "debugpy/_vendored/__init__.py", line 18, in <module> FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/2n/h8v95wf976v7byjf7s78jfxh0000gn/T/_MEIu7ujzo/debugpy/_vendored' I took this qtconsole code from the qtconsole github: "https://github.com/jupyter/qtconsole/blob/master/examples/embed_qtconsole.py." Thank you in advance for your help.
TypeError: __init__ missing 1 required positional argument: 'to', I get this error when I make migrations "python3 manage.py makemigrations"
Python 3.8.10, django version 3.2.9. When I am running the following code: "python3 manage.py makemigrations auth_app" ... I get this error: TypeError: init() missing 1 required positional argument: 'to'. I've checked out everything that says the error and still get the same.This is the whole error message. Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/allfsr/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/home/allfsr/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute django.setup() File "/home/allfsr/.local/lib/python3.8/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/allfsr/.local/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/home/allfsr/.local/lib/python3.8/site-packages/django/apps/config.py", line 301, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 848, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/allfsr/Documents/C4_WD/BANK/backend_auth/auth_app/models/__init__.py", line 1, in <module> from .account import Account File "/home/allfsr/Documents/C4_WD/BANK/backend_auth/auth_app/models/account.py", line 4, in <module> class Account(models.Model): File "/home/allfsr/Documents/C4_WD/BANK/backend_auth/auth_app/models/account.py", line 6, in Account user = models.ForeignKey(related_name='account', on_delete= models.CASCADE) TypeError: __init__() missing 1 required positional argument: 'to'
ModuleNotFoundError in django when adding app
Django can't find my app and it shows me "ModuleNotFoundError" when I try to run server my web this is my setting.py : INSTALLED_APPS = [ ...... 'djmoney', 'transition', --> this is my app ] and this is the complete error : Exception in thread django-main-thread: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.8/dist-packages/django/utils/autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/django/core/management/commands/runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "/usr/local/lib/python3.8/dist-packages/django/utils/autoreload.py", line 76, in raise_last_exception raise _exception[1] File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 357, in execute autoreload.check_errors(django.setup)() File "/usr/local/lib/python3.8/dist-packages/django/utils/autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python3.8/dist-packages/django/apps/registry.py", line 91, in populate app_config = AppConfig.create(entry) File "/usr/local/lib/python3.8/dist-packages/django/apps/config.py", line 90, in create module = import_module(entry) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'transition'
A possible reason for this error is your project directory structure. If this is indeed the case, you should change it to xxx.transition, where xxx = the name of your project.
Core API: AttributeError: module 'click' has no attribute 'style'
I am a beginner in Django REST framework and while going through this part of the tutorial I faced and error. I installed coreapi and did the desired changes to the code but when I try to run the server, I face this problem: Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f6220bd6268> Traceback (most recent call last): File "/home/atenagm/.local/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run self.check(display_num_errors=True) File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/management/base.py", line 385, in check include_deployment_checks=include_deployment_checks, File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/management/base.py", line 372, in _run_checks return checks.run_checks(**kwargs) File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/checks/urls.py", line 14, in check_url_config return check_resolver(resolver) File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/checks/urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "/home/atenagm/.local/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/atenagm/.local/lib/python3.5/site-packages/django/urls/resolvers.py", line 310, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/atenagm/.local/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/atenagm/.local/lib/python3.5/site-packages/django/urls/resolvers.py", line 303, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 665, in exec_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "/home/atenagm/tutorial/tutorial/tutorial/urls.py", line 21, in <module> url(r'^', include('snippets.urls')), File "/home/atenagm/.local/lib/python3.5/site-packages/django/conf/urls/__init__.py", line 50, in include urlconf_module = import_module(urlconf_module) File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 665, in exec_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "/home/atenagm/tutorial/tutorial/snippets/urls.py", line 2, in <module> from snippets import views File "/home/atenagm/tutorial/tutorial/snippets/views.py", line 2, in <module> from snippets.serializers import SnippetSerializer, UserSerializer File "/home/atenagm/tutorial/tutorial/snippets/serializers.py", line 1, in <module> from rest_framework import serializers File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py", line 30, in <module> from rest_framework.compat import JSONField as ModelJSONField File "/usr/local/lib/python3.5/dist-packages/rest_framework/compat.py", line 170, in <module> import coreapi File "/usr/local/lib/python3.5/dist-packages/coreapi/__init__.py", line 2, in <module> from coreapi import auth, codecs, exceptions, transports, utils File "/usr/local/lib/python3.5/dist-packages/coreapi/auth.py", line 1, in <module> from coreapi.utils import domain_matches File "/usr/local/lib/python3.5/dist-packages/coreapi/utils.py", line 2, in <module> from coreapi.compat import string_types, text_type, urlparse, _TemporaryFileWrapper File "/usr/local/lib/python3.5/dist-packages/coreapi/compat.py", line 56, in <module> console_style = click.style AttributeError: module 'click' has no attribute 'style' I couldn't find any solution to this error. Any suggestions?