0

I forked https://github.com/arneb/django-messages/ and put it in my repo: https://github.com/mike-johnson-jr/django-messages/

As I am using the package, I get the error in the title. Full traceback:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/michael/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/michael/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/home/michael/.local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/michael/.local/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
    app_config.import_models()
  File "/home/michael/.local/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/michael/.local/lib/python3.6/site-packages/django_messages/models.py", line 48, in <module>
    class Message(models.Model):
  File "/home/michael/.local/lib/python3.6/site-packages/django_messages/models.py", line 87, in Message
    get_absolute_url = reverse(get_absolute_url)
  File "/home/michael/.local/lib/python3.6/site-packages/django/urls/base.py", line 90, in reverse
    return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  File "/home/michael/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 562, in _reverse_with_prefix
    self._populate()
  File "/home/michael/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 413, in _populate
    for url_pattern in reversed(self.url_patterns):
  File "/home/michael/.local/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/michael/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 533, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/michael/.local/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/michael/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 526, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/michael/projects/datafix/datafix/urls.py", line 65, in <module>
    path('messages/', include('django_messages.urls')),
  File "/home/michael/.local/lib/python3.6/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/michael/.local/lib/python3.6/site-packages/django_messages/urls.py", line 4, in <module>
    from django_messages.views import *
  File "/home/michael/.local/lib/python3.6/site-packages/django_messages/views.py", line 11, in <module>
    from django_messages.models import Message
ImportError: cannot import name 'Message'

And here the my django_messages.models code:

@python_2_unicode_compatible
class Message(models.Model):
    """
    A private message from user to user
    """
    subject = models.CharField(_("Subject"), max_length=140)
    body = models.TextField(_("Body"))
    sender = models.ForeignKey(AUTH_USER_MODEL, related_name='sent_messages', verbose_name=_(
        "Sender"), on_delete=models.SET_NULL)
    recipient = models.ForeignKey(AUTH_USER_MODEL, related_name='received_messages',
                                  null=True, blank=True, verbose_name=_("Recipient"), on_delete=models.SET_NULL)
    parent_msg = models.ForeignKey('self', related_name='next_messages', null=True,
                                   blank=True, verbose_name=_("Parent message"), on_delete=models.SET_NULL)
    sent_at = models.DateTimeField(_("sent at"), null=True, blank=True)
    read_at = models.DateTimeField(_("read at"), null=True, blank=True)
    replied_at = models.DateTimeField(_("replied at"), null=True, blank=True)
    sender_deleted_at = models.DateTimeField(
        _("Sender deleted at"), null=True, blank=True)
    recipient_deleted_at = models.DateTimeField(
        _("Recipient deleted at"), null=True, blank=True)

    objects = MessageManager()

Does anyone know what's wrong? Thanks in advance for the help.

Mike Johnson Jr
  • 776
  • 1
  • 13
  • 32

1 Answers1

0

Error was in my django_messages.models.Message code, get_absolute_url() was wonky.

Mike Johnson Jr
  • 776
  • 1
  • 13
  • 32
  • As it sits, this answer doesn't help anyone else having the same issue. Please put specifically what you did to resolve the issue so another person searching for this same issue knows how to fix it. – dfundako Jan 22 '19 at 20:33