Hi people, I am having some problem to validate a data in my application. I will try to simply the model in here to help you guys to understand the problem. I have 2 models:
class Clip(models.Model): is_approved = models.BooleanField(default=False) language = models.ForeignKey(Language) class ClipDescription(models.Model): clip = models.ForeignKey(Clip) text = models.TextField() language = models.ForeignKey(Language) I am editing via ModelAdmin. I defined a ClipModelAdmin class as above (simplified): class ClipAdmin(admin.ModelAdmin): inlines = [ ClipDescriptionInline ] So, as you can see, both Clip and ClipDescription are edited in the same page (using the 'inlines' feature). But the rule is: if the user trigger the 'Save' action, the attribute Clip.is_approved can be True only if there is a ClipDescription instance associated to the Clip instance, having the same language. For example, if I have a clip with id=1, language=english and is_approved=True, it can be saved only if there is a clip description with clip_id=1, language=english. If not, I want to show the error message 'Cannot approve this clip without having a description in English' in the form. I have already read the official documentation and tried to work with validators, tried to define a ModelForm and its clean_is_approved method, among other workarounds. And I still couldn't make this work. The problem is at the clean_is_approved context I couldn't figure out how to get access to the form data that is being entered at that moment, to retrieve the Clip descriptions. I don't if I was clear enough, I can give more details. Any ideas and suggestions will be very appreciated. Thank you very much for your attention. Kind regards, Gabriel Gabriel de Carvalho Nogueira Reis Software Developer +44 7907 823942--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-us...@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.