I have the following class:
class Option(models.Model):
default = models.BooleanField(default=False)
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
I have another class which uses it:
class Type(models.Model):
''' more properties here '''
options = models.ManyToManyField(Option, blank=True)
The idea would be that in django's admin site I would be able to manually add Option
instances to a Type
.
Now, I already created 4 instances of Option
in the admin site.
When I go to the Type
configuration, to options
, all 4 instances are already there. I'd like that box to be empty and add them manually, because for every instance of Type
the list should be different.
How can I do that? Something is telling me that I misunderstood ManyToManyField
... :)
EDIT: Adding the ModelAdmin
class for Option
:
class OptionAdmin(admin.ModelAdmin):
options = forms.ModelMultipleChoiceField(queryset=Option.objects.all(), widget=FilteredSelectMultiple("verbose name", is_stacked=False))