Hi, I am using a package called Django Embed Video
<https://github.com/jazzband/django-embed-video> for my project. It comes
with a EmbedVideoField for the model and validation for the URL which
checks whether the URL is Youtube or Vimeo.
It raises exceptions when using generic create view without using
customised form(form_class). However, when I use a customised form because
I want to customise the widgets and css classes, it doesn't raise any
exceptions. Why is that? Is there a way get the exceptions working with
form_class?
Another thing is that the data is saved to the db which I can see in Django
admin. But it is not included in the generic list view. Why?
*models.py*
from django.db import models
from embed_video.fields import EmbedVideoField
Class Video(models.Model):
title = models.CharField(max_length=30)
description = models.TextField(blank=True)
url = EmbedVideoField(verbose_name=‘video’)
*views.py*
from django.views.generic.edit import CreateView
from django.views.generic.list import ListView
class VideoCreate(CreateView):
model = Video
form_class = NewVideoForm
class VideoList(ListView):
model = Video
ordering = ["-created"]
*forms.py*
from django import forms
from .models import Video
class NewVideoForm(forms.ModelForm):
description = forms.CharField(widget=forms.Textarea(),
required=False,
max_length=4000,
help_text='The max length of the text is
4000.')
url = forms.URLField(label='video', help_text='Please enter a Youtube or
Vimeo link.')
class Meta:
model = Video
fields = ['title', 'description', 'url']
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/036a9a78-960b-44f0-87ca-795168629785%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.