Skip to content
New issue

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

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

Already on GitHub? # to your account

Custom WAFFLE_FLAG_MODEL not working after 0.15 #380

Open
aleehedl opened this issue Aug 20, 2020 · 1 comment
Open

Custom WAFFLE_FLAG_MODEL not working after 0.15 #380

aleehedl opened this issue Aug 20, 2020 · 1 comment

Comments

@aleehedl
Copy link
Contributor

aleehedl commented Aug 20, 2020

I have added a custom waffle flag which inherits from the AbstractBaseFlag and doesn't have a users field. After upgrading waffle to a newer version I get the following error during startup:

Traceback (most recent call last):
  File "manage.py", line 30, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute
    django.setup()
  File "/usr/local/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/usr/local/lib/python3.8/site-packages/waffle/apps.py", line 9, in ready
    import waffle.signals  # noqa: F401
  File "/usr/local/lib/python3.8/site-packages/waffle/signals.py", line 7, in <module>
    @receiver(m2m_changed, sender=get_waffle_flag_model().users.through)
AttributeError: type object 'Flag' has no attribute 'users'

The docs say that the Flag needs to be a subclass of AbstractBaseFlag yet the signal receiver is accessing the users field which is only found in AbstractUserFlag. I'm guessing this is the breaking commit: afb2660. How should I go about this problem?

@aleehedl
Copy link
Contributor Author

My current workaround to get the app running:

class Flag(AbstractBaseFlag):
    class MockM2MRelation:
        through = None

    users = MockM2MRelation()
    groups = MockM2MRelation()
    # ...

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant