On Jun 24, 10:51 am, Masklinn <maskl...@masklinn.net> wrote:
> On 2011-06-24, at 10:47 , Simone Dalla wrote:
>
> > 2011/6/24 Bussiere <bussi...@gmail.com>
>
>>> And i want that when a user record an actor in the admin interface it
>>> create automatically a webpage associated wit(h the actor.
>>> I now how to create the webpage in my model, but i want to call a function
>>> each time someone record an actor in the administration menu.
>
>
> >https://docs.djangoproject.com/en/1.3/topics/db/models/#overriding-mo...
>
> This creates a strong coupling between the model

Which may OR NOT be a problem - there's nothing wrong with coupling
two classes when they're intended to work together.

@OP: if you use the first solution, the Actor class will depend on the
Webpage class. If you use the signal solution, Actor will not know
anything about Webpage, so you can later reuse Actor without Webpage.
Which solution is best really depends on your needs.

Also:

>>> And i want that when a user record an actor in the admin interface it
>>> create automatically a webpage associated with the actor.

Whether you override Actor.save or use a signal, a Webpage will be
created WHENEVER an Actor is created - even if it's not created thru
the admin interface. If you only want to have the webpage created when
the Actor is created thru the admin interface, you might be better
overriding the ActorAdmin.save_model method (https://
docs.djangoproject.com/en/1.3/ref/contrib/admin/
#django.contrib.admin.ModelAdmin.save_model). Note that you can have
your cake and eat it to: if you don't want to still use signals, you
can define your own signals in the app where's the Actor model is
defined, override ActorAdmin.save_model to just send your own custom
signal, and - in another app - connect a receiver for this signal that
will create the associated webpage.

HTH

-- 
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.

Reply via email to