Re: access current model id, for custom widget

2008-11-25 Thread yves_s
I want that only dogs (no other animals from other groups) are listed in the foreignkey drop down box for the representative_animal (which would be all animals without modification) when I'm editing the AnimalGroup dogs. I finally hacked something together with the threadlocals middleware, which

Re: access current model id, for custom widget

2008-11-24 Thread Donn
Sorry for being dense, but I don't really follow what you need. Look in the docs for backward relationships between foreign keys. That may help you. Something like: group = Animal.objects.get(animal_group__id=XX) But I don't know where you decide what XX is. \d --~--~-~--~~---

Re: access current model id, for custom widget

2008-11-24 Thread yves_s
thanks for the replies donn and malcolm, here in more detail what I want to archive perhaps I'm on the totally wrong track... How do I pass the PASSANYTHINGHERE=whatever parameters to the widget (see sample code)? (the super part is clear, thanks) How to pass the "value" id on ModelForm level to t

Re: access current model id, for custom widget

2008-11-24 Thread Malcolm Tredinnick
On Mon, 2008-11-24 at 13:07 +0200, Donn wrote: > Further info, > Looks like from within a widget there's no easy way to find the Form. I'd a > thunk there'd be a Parent attribute, but there ain't. The way Django does this is fairly normal design practice. Normal OO implementation practice is th

Re: access current model id, for custom widget

2008-11-24 Thread Donn
Further info, Looks like from within a widget there's no easy way to find the Form. I'd a thunk there'd be a Parent attribute, but there ain't. So: If you are doing something like this: class SomeWidget( forms.TextInput ): def __init__(self,attrs=None, PASSANYTHINGHERE=whatever ):

Re: access current model id, for custom widget

2008-11-24 Thread Donn
On Monday, 24 November 2008 12:21:55 yves_s wrote: > does anybody have some hints? IIRC - You can do: form.instance (inside your widget, I think...) This assumes you made a form with something like: f = MyForm(instance = someInstance) On the command-line, try using: python manage.py shell Then i

Re: access current model id, for custom widget

2008-11-24 Thread yves_s
does anybody have some hints? On 21 Nov., 00:24, yves_s <[EMAIL PROTECTED]> wrote: > hi everybody > I'm making a custom form widget in the newforms admin and I want to > have access to the id of the current model instance (for already > existing data). > Can I get the id from the request object?

access current model id, for custom widget

2008-11-20 Thread yves_s
hi everybody I'm making a custom form widget in the newforms admin and I want to have access to the id of the current model instance (for already existing data). Can I get the id from the request object? Or any other solution? I'm really going mad with this problem.. yves --~--~-~--~--