Re: rendering values from ManyToMany fields

2009-04-13 Thread Adam Fraser
figured it out! class ModelForm(forms.ModelForm): ''' Define our own model forms so we can use the form to render a read-only detail page. ''' def __init__(self, *args, **kwargs): readonly = kwargs.get('readonly', False) if readonly: del

Re: rendering values from ManyToMany fields

2009-04-13 Thread Adam Fraser
Okay, so I should probably be dealing with the field in my ModelForm class (the one that subclasses ModelForm). This code is where the display values are found before creating the ReadOnlyWidget. In the case of my stains field (a ManyToMany field), there isn't a get_stains_display function, so

Re: rendering values from ManyToMany fields

2009-04-10 Thread Malcolm Tredinnick
On Fri, 2009-04-10 at 12:16 -0700, Adam Fraser wrote: [...] > The problem I'm running into is that the value that comes into render > for the ManyToManyField is a list of the id's for the selected stains > and not the stains themselves. I assume I should be getting them > somehow through the

rendering values from ManyToMany fields

2009-04-10 Thread Adam Fraser
Hello, I'm using a ManyToManyField to model a relationship where a "Project" object may have many different "Stain" objects. The code is working successfully and looks like this class Stain(models.Model): def __unicode__(self): return unicode(self.name) name =