Not raising exception when using form_class in generic CreateView

8 views
Skip to first unread message

Tony

unread,
Feb 11, 2018, 6:32:54 PM2/11/18
to Django users
Hi, I am using a package called 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']


Reply all
Reply to author
Forward
0 new messages