mirror of
https://github.com/Hopiu/django-embed-video.git
synced 2026-05-13 07:03:11 +00:00
Fix: allow empty field
This commit is contained in:
parent
1a244eb75c
commit
1d41a26071
1 changed files with 8 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue