I have a class in models.py like:

    class UserProfile(models.Model):
        user = models.ForeignKey(User)
        is_counter = models.BooleanField()
        is_student = models.BooleanField()

        def save(self):
            if self.is_counter != self.is_student:
                super(UserProfile, self).save()
            else:
                return False

I have defined two types of user, either it can be a student or counterbut
never both.
I do not want the user to be both coutner as well as student. So, I defined
a custom save() such that entry is added to database when is_counter !=
is_student.

Now, when I use Admin interface to add inconsistent entry, the interface
says entry added successfully but "actually" it isn't added. How can I add
an error message that will be displayed when *False* is returned by save().

-- 
Regards,
Abhijeet Rastogi (shadyabhi)
http://www.google.com/profiles/abhijeet.1989

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