I have a model in Django:
class Task(models.Model):
product = models.ForeignKey(Product)
content = models.OneToOneField(ContentDataSet)
How can I use option limit_choices_to=
for content
field if I want to show only not yet assigned ContentDataSet
options AND already assigned to this Task options in user/admin in standart drop-down choicelist?
I tried to use limit_choices_to = {'task__isnull':True}
, but in that case I can't see already assigned to this Task content
options.
limit_choices_to = models.Q(task__isnull=True) | models.Q(task=self)
is not working because self
is not defined