On 3/29/06, Rudolph <[EMAIL PROTECTED]> wrote:
>
> I'm writing a _manipulator_validate_.....() method. These methods
> become methods for the manipulator of a model and will be validated
> before save() is called. Any exception of  validators.ValidationError
> will very nicely be displayed in the admin interface (if your raise
> such an exception in _pre_save, it won't work that way :-( ).
>
> By Googling around I discovered that self.original_object points to the
> old object. Which can be very helpfull. But I would also like to access
> other objects from the same model (by using get_object or get_list on
> the module). Is there a way to do this? It must be possible (for
> example to check if the new value is unique for the whole model, or to
> check if a value exists in another field of another object).
>
> I'm using the current trunk but willing to change to Magic Removal if
> that solves it.
>
> Thanks in advance!
>
> R.
>
>

No need to use magic removal. Just import you model modules inside of
the _manipulator_validate_...() method like so:

class Foo(meta.Model):
    myfield = meta.CharField(maxlength=30)

    def _manipulator_validate_myfield(self, field_data, all_data):
        from django.models.myapp import foos
        ...

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

Reply via email to