I am thinking about splitting my model's save() method over few signals.
For example, stripping spaces and making string capitalized.
I have even more sophisticated problems such as making an object field
active set to False basing on various parameters from other fields, such as
expiration date, or good or bad karma points.
What do you think, it is generally good idea, to keep models file clean out
of heavily overloaded save() methods?
How about making more than one signal pre_save to the same model?
@receiver(pre_save, sender=X)
def strip_chars(sender, **kwargs):
pass
@receiver(pre_save, sender=X)
def capitalize_name(sender, **kwargs):
pass
@receiver(pre_save, sender=X)
def make_inactive(sender, **kwargs):
pass
Will it work?
I want to put those in signals/X.py
where X is my model name
Where to import them? in my model file?
or it will happen "automagicly" like with admin.py file?
(I think that python's explicit rule forbids that way, therefore where to
import those signals, avoiding recurring imports [signal.py import model.py
and model imports signals])?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.