Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error when using in projects without django CMS #55

Open
MacLake opened this issue Jan 23, 2025 · 3 comments · May be fixed by #56
Open

Import error when using in projects without django CMS #55

MacLake opened this issue Jan 23, 2025 · 3 comments · May be fixed by #56
Labels
bug Something isn't working

Comments

@MacLake
Copy link
Contributor

MacLake commented Jan 23, 2025

I have added an HTMLField to a model in a project without django CMS, which should work according to the docs:

from djangocms_text.fields  import HTMLField
#…
class Member(models.Model):
   # …
   description = HTMLField(blank=True, verbose_name=_('description'), help_text=_('Description of the member'))

But after starting runserver I get an import error: ModuleNotFoundError: No module named 'cms'

/home/jens/develop/ph-portal/.venv/bin/python /home/jens/develop/ph-portal/manage.py runserver localhost:8003 
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/home/jens/.rye/py/[email protected]/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/home/jens/.rye/py/[email protected]/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 126, in inner_run
    autoreload.raise_last_exception()
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 394, in execute
    autoreload.check_errors(django.setup)()
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate
    app_config.import_models()
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jens/.rye/py/[email protected]/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/jens/develop/ph-portal/accounts/models/__init__.py", line 7, in <module>
    from .invite_passipedia_request import InvitePassipediaRequest
  File "/home/jens/develop/ph-portal/accounts/models/invite_passipedia_request.py", line 5, in <module>
    from ipha.models import Member
  File "/home/jens/develop/ph-portal/ipha/models/__init__.py", line 6, in <module>
    from .contactperson import ContactPerson
  File "/home/jens/develop/ph-portal/ipha/models/contactperson.py", line 9, in <module>
    from .member import Member
  File "/home/jens/develop/ph-portal/ipha/models/member.py", line 13, in <module>
    from djangocms_text.fields  import HTMLField
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/djangocms_text/fields.py", line 7, in <module>
    from .widgets import TextEditorWidget
  File "/home/jens/develop/ph-portal/.venv/lib/python3.11/site-packages/djangocms_text/widgets.py", line 17, in <module>
    from cms.utils.urlutils import admin_reverse, static_with_version
ModuleNotFoundError: No module named 'cms'
@fsbraun
Copy link
Member

fsbraun commented Jan 23, 2025

Good catch! Will check!

@fsbraun fsbraun added the bug Something isn't working label Jan 23, 2025
@fsbraun fsbraun linked a pull request Jan 23, 2025 that will close this issue
@fsbraun
Copy link
Member

fsbraun commented Jan 23, 2025

@MacLake Can you check if #56 works for you?

@MacLake
Copy link
Contributor Author

MacLake commented Jan 23, 2025

Now it fails in utils.py at line 8:

from cms import __version__
from cms.utils.urlutils import admin_reverse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants