Closed BoPeng closed 1 year ago
Hey! Could you provide more details regarding what stopped working exactly? The unit tests are currently running for Django 4.1, as you can see here. Note that django-haystack is still missing a release with support for the latest Django versions, so you may have to install a development version of this package to have it working (like this is done in Django-machina's CI).
Thanks for the info. Upon updating from django 4.0.8
to 4.1.3
(tried 4.1.0
as well), one of my unit tests regarding displaying unread topics failed. It may be due to django-machina
or maybe my surrounding code so I thought that I would check machina
first. Let me update my haystack
and see if it solves the problem.
ok, the problem is with the removal of default_app_config
as listed in the Django 4.1 changelog. However, the problem is a bit more complicated.
My existing code has default_app_config
, with apps.py
having
from machina.apps.forum_tracking.apps import (
ForumTrackingAppConfig as BaseForumTrackingAppConfig,
)
class ForumTrackingAppConfig(BaseForumTrackingAppConfig):
name = 'mysite.forum_tracking'
default_auto_field = 'django.db.models.AutoField'
However, this breaks the django app config machinism because this module now defines two AppConfig
, BaseForumTrackingAppConfig
and ForumTrackingAppConfig
. For some reason, django does not produce any warning so the entire app is not imported and the topic_view
signal is not processed.
The solution, as explains in the documentation, is to add default=True
as follows,
class ForumTrackingAppConfig(BaseForumTrackingAppConfig):
name = 'mysite.forum_tracking'
default_auto_field = 'django.db.models.AutoField'
default = True
However, another solution should be specifying the app directly and use
INSTALLED_APPS = [
...
"mysite.forum_tracking.apps.ForumTrackingAppConfig"
...
This, however, does not work because it breaks get_class
.
File "/app/bioworkflows/forum_tracking/models.py", line 4, in <module>
from machina.apps.forum_tracking.abstract_models import AbstractTopicReadTrack
File "/usr/local/lib/python3.11/site-packages/machina/apps/forum_tracking/abstract_models.py", line 16, in <module>
ForumReadTrackManager = get_class('forum_tracking.managers', 'ForumReadTrackManager')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/machina/core/loading.py", line 16, in get_class
return get_classes(module_label, [classname, ])[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/machina/core/loading.py", line 31, in get_classes
raise AppNotFoundError('No app found matching \'{}\''.format(module_label))
machina.core.loading.AppNotFoundError: No app found matching 'forum_tracking.managers'
I encountered this problem before when trying to specify AppConfig
in INSTALLED_APPS
and may have submitted a ticket for it.
Let me see if I can come up with a PR to fix get_class
.
https://github.com/ellmetha/django-machina/issues/229 is the ticket I submitted before. A PR is now submitted.
I updated my project from django 4.0.8 to 4.1.3 and
forum-tracking
stopped working. I am not entirely sure if this is a problem from my project or fromdjango-machina
since I customizeddjango-machina
quite a bit.@ellmetha Could you let me know if the test suite of
django-machina
passes for django 4.1.x? I do notice that the current documentation says thatdjango-machina
is only compatible with4.0.x
.