Marcin Jurczuk wrote: > Hello, > I'm writing my own validator based on shipped with django and wondering > how get validated object.id field ?
Validators come in two varieties: those linked to field definitions in models and those that linked to field definitions in custom manipulators. With first kind you can't get the object's id. They just deal with plain data. The second kind is more flexible since you can write your manipulator as you like it. For example: class MyManipulator(MyModel.ChangeManipulator): def __init__(self, object_id): MyModel.ChangeManipulator.__init__(self, object_id) # add new validator to some field's validators fields[2].validator_list.append(self.validate_field) def validate_field(self, data, all_data): self.original_object # this is the object The main disadvantage of this approach is that you can't use it with generic views since they won't use your custom manipulator. I remember that some was trying to solve this problem on this list but don't remember results of the effort. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---