From 1d41a2607125342886aa85109ba51bb3cb12dc85 Mon Sep 17 00:00:00 2001 From: Juda Kaleta Date: Tue, 25 Jun 2013 15:57:12 +0200 Subject: [PATCH] Fix: allow empty field --- embed_video/fields.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/embed_video/fields.py b/embed_video/fields.py index 5f107c4..ec112f3 100644 --- a/embed_video/fields.py +++ b/embed_video/fields.py @@ -26,11 +26,13 @@ class EmbedVideoField(models.URLField): class EmbedVideoFormField(forms.URLField): def validate(self, url): super(EmbedVideoFormField, self).validate(url) - try: - detect_backend(url) - except UnknownBackendException: - raise forms.ValidationError(_(u'URL could not be recognized.')) - except NoIdFound: - raise forms.ValidationError(_(u'Video Id not found .')) + + if url: + try: + detect_backend(url) + except UnknownBackendException: + raise forms.ValidationError(_(u'URL could not be recognized.')) + except NoIdFound: + raise forms.ValidationError(_(u'Video Id not found .')) return url