On May 16, 6:27 am, Greg Taylor <[EMAIL PROTECTED]> wrote:
> class Form_SKU(ModelForm):
> """
> The form for updating SKUs.
> """
> selected = self.instance.colors
``self`` isn't in scope here, try the code below (and it wouldn't hurt
to read-up on Python OOP).
class Form_SKU(Mod
To elaborate, I can't do a self.instance, as it errors saying "self is
not defined". For example:
color_field =
forms.ModelMultipleChoiceField(queryset=self.instance.colors)
I need to find the difference of two lists on a model to form the
queryset in my application.
--~--~-~--~~
Is there a way to get the value of the 'instance' keyword argument
from within a Form sub-classed by ModelForm? For example:
class CS_SKU(models.Model):
colors = models.ManyToManyField(Color, blank=True, null=True)
color_field = forms.ModelMultipleChoiceField(queryset=colors)
class Form_
3 matches
Mail list logo