Giter Site home page Giter Site logo

Comments (4)

ellmetha avatar ellmetha commented on May 28, 2024

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).

from django-machina.

BoPeng avatar BoPeng commented on May 28, 2024

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.

from django-machina.

BoPeng avatar BoPeng commented on May 28, 2024

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.

from django-machina.

BoPeng avatar BoPeng commented on May 28, 2024

#229 is the ticket I submitted before. A PR is now submitted.

from django-machina.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.