ManyToMany model field where choices change based on boolean

I'm relatively new to Django, and I've been trying to find a way to implement a ManyToMany field whose visible 'choices' within the UI change based upon a BooleanField found within the same model.

For instance, suppose I have a model that represents different jobs, and a worker model that has a manytomany relationship to this jobs model. Suppose also that there are two types of workers: a manager and non-manager which is represented as a BooleanField. If you are a manager, you have certain jobs that a worker does not have and vice versa.

I'm trying to find a way, without creating a new table, to have it such that the jobs listed within the manytomany relationship are dependent on the boolean value of 'is_manager'. That is, if you were to click 'is_manager', this should list manager-specific jobs, yet these manager specific jobs live within the same table as non-manager jobs -- those would just be blank.

I've been looking into the through field, etc, but all solutions that I come up with seem to be dependent on making another table. I'm sure there is a way to do this better though.

Thank you.


I suggest this approach:

class MyModelForm(forms.ModelForm):
    class Meta:
        model = MyModel
        fields = ['jobs', 'username']

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        instance = kwargs.get('instance', None)
        if instance is not None:
            if instance.is_manager:
                self.fields['jobs'].queryset = Jobs.objects.filter(manager=True)
                self.fields['jobs'].queryset = Jobs.objects.filter(manager=False)


 ? jquery toggle from several multiple select
 ? how to get the clicked option in bootstrap selectpicker?
 ? Setting multiple javabeans properties from a multiple select
 ? Django Forms: MultipleSelect with choices from another model (Foreign Key)
 ? Remove initial selected item in jQuery ASM select
 ? PHP email form multiple select
 ? How to indicate to user that a command affects a subset of a multiple selection?
 ? Problem implementing a UITableView that allows for multiple row selections
 ? Rails multiple select box issue for search
 ? What will you do to optimize MySQL performance in this case?