jazzband / django-waffle

A feature flipper for Django
https://waffle.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.13k stars 259 forks source link

CREATE_MISSING_FLAGS should be handled in .get() instead of is_active() #400

Open honzakral opened 3 years ago

honzakral commented 3 years ago

I am using the Flags in other scenarios aside from just views (celery tasks for example) and I was surprised that the CREATE_MISSING_FLAGS setting wasn't respected (I am manually calling is_active_for_user and other, custom, methods I created based on the example) and the methods were failing with error:

ValueError: "<CustomFlag: flag_name>" needs to have a value for field "id" before this many-to-many relationship can be used.

In my mind there should be a way to check if a flag is active using similar mechanism to waffle.flag_is_active which would work and respect the CREATE_MISSING_FLAGS setting, simplest solution seems to move the logic from is_active to get(). I would be happy to submit a PR if this would be considered a useful addition.

btel commented 2 years ago

I have same issue. The solution suggested by @HonzaKral seems reasonable. Is there any interest in such a PR?

clintonb commented 2 years ago

Yes, PRs are welcome.

clintonb commented 2 years ago

This feature was reverted. See https://github.com/django-waffle/django-waffle/issues/435 for some details. Please modify the logic to ensure it supports flags, switches, and samples.