Re: Overrding queryset on a field in form generated with ModelForm

2009-02-07 Thread mrsource
Solved, I corrected the __init__ method with this: def __init__(self, *args, **kwargs): super(CategoriaForm,self).__init__(*args,**kwargs); if kwargs.has_key('instance'): self.fields['parent'].queryset = Categoria.objects.exclude

Re: Overrding queryset on a field in form generated with ModelForm

2009-02-05 Thread mrsource
Maybe I missing some step: I trying to set up the the automatic admin page form to edit a category tree builded with treebeard extension: #Model: class Categoria(AL_Node,Componente): immagine = fields.ImageWithThumbnailsField (upload_to=Componente.image_path + 'categorie/',

Re: Overrding queryset on a field in form generated with ModelForm

2009-01-02 Thread Malcolm Tredinnick
On Fri, 2008-12-26 at 23:13 -0800, Tony Chu wrote: > Thank you very much Malcolm. The methods I listed above has worked for > me so far - so your response is reassuring. > > I was just surprised that no one had encountered a similar need > already. The concept here is parallel to getting a list

Re: Overrding queryset on a field in form generated with ModelForm

2008-12-26 Thread Tony Chu
Thank you very much Malcolm. The methods I listed above has worked for me so far - so your response is reassuring. I was just surprised that no one had encountered a similar need already. The concept here is parallel to getting a list of territories in a country, dynamically fetched based on

Re: Overrding queryset on a field in form generated with ModelForm

2008-12-10 Thread Malcolm Tredinnick
On Wed, 2008-12-10 at 00:18 -0800, Tony Chu wrote: > Hi All, > > I was using the ModelForm to generate my first form in Django. > ModelForm is great. However, I had wanted to dynamically limit the > selection of Foreign keys to a subset I generate. > > The only way I found after a lot of

Overrding queryset on a field in form generated with ModelForm

2008-12-10 Thread Tony Chu
Hi All, I was using the ModelForm to generate my first form in Django. ModelForm is great. However, I had wanted to dynamically limit the selection of Foreign keys to a subset I generate. The only way I found after a lot of trial and error was the following: form['foreignkey'].field.queryset