Re: how to automatically call an additional function on saving a model?

2009-02-15 Thread Alex Gaynor
On Sun, Feb 15, 2009 at 5:09 PM, Gabor Nyers  wrote:

>
> Hi all,
>
> I'm learning Django (and for that matter Python) for 2 weeks now and bumped
> into a problem I've been struggling with a
> few days. Apologies if it's obvious, but I've been looking at the Django
> documentation for 2 days now. It might be
> there, but in that case I think I keep missing it. Can someone drop me a
> line with a suggestion how to solve this (or
> where to look)?
>
> I have two models:
> - Request
> - RequestItem
>
> A Request contains multiple Request items. I'm using the Admin interface
> like this:
>
> class RequestItemInline (admin.TabularInline):
>model = ResourceRequestItem
>
> class RequestAdmin(admin.ModelAdmin):
>model = Request
>inlines = [ RequestItemInline ]
>
> I want to automatically call a function for every RequestItem object each
> time I'm saving a RequestAdmin form. This
> function is defined in RequestItem's model.
>
> Any suggestions?
>
> Regards,
> Gábor
>
> >
>
I'm not 100% I follow, but you're looking for one of these 2 methods:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-model-self-request-obj-form-change

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to automatically call an additional function on saving a model?

2009-02-15 Thread Gabor Nyers

Hi all,

I'm learning Django (and for that matter Python) for 2 weeks now and bumped 
into a problem I've been struggling with a
few days. Apologies if it's obvious, but I've been looking at the Django 
documentation for 2 days now. It might be
there, but in that case I think I keep missing it. Can someone drop me a line 
with a suggestion how to solve this (or
where to look)? 

I have two models: 
- Request
- RequestItem

A Request contains multiple Request items. I'm using the Admin interface like 
this:

class RequestItemInline (admin.TabularInline):
model = ResourceRequestItem

class RequestAdmin(admin.ModelAdmin):
model = Request
inlines = [ RequestItemInline ]

I want to automatically call a function for every RequestItem object each time 
I'm saving a RequestAdmin form. This
function is defined in RequestItem's model.

Any suggestions?

Regards,
Gábor

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---