Hi Shawn,
Thanks for the feedback. I read the docs and defined a clean_audio_file
method in my ModelAdmin class. I dropped the Podcast table, made the field
not mandatory in the model and did a syncdb (to test my clean method).
Still a podcast can be saved without the audio_file: the code in the clean
method does not appear to run. Please see the code below:
class PodcastAdmin(admin.ModelAdmin):
list_display = ('title', 'audio_file', 'active', 'user')
def clean_audio_file(self, request, obj, form, change):
data = self.cleaned_data['audio_file']
if not data or len(data) < 1 or data == "":
raise forms.ValidationError("Provide a file!")
return data
admin.site.register(Podcast, PodcastAdmin)
Am at a loss.
On Wed, Mar 30, 2011 at 4:37 PM, Shawn Milochik <[email protected]> wrote:
> No, the forms.ValidationError has to be raised in one of the clean()
> methonds of your model. Otherwise it will result in a stack trace.
>
>
> --
> 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.
>
--
Regards,
Sithembewena Lloyd Dube
--
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.