Skip to content

Commit

Permalink
refactor: use CreateView instead, #10
Browse files Browse the repository at this point in the history
  • Loading branch information
escaped committed Oct 7, 2018
1 parent 8c3135b commit 3d44fee
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions test_proj/media_library/views.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
from django import forms
from django.views.generic import FormView
from django.views.generic import CreateView

from video_encoding.fields import VideoField

from .models import Video


class VideoForm(forms.ModelForm):

class Meta:
fields = ('file',)
model = Video


class VideoFormView(FormView):
form_class = VideoForm
class VideoFormView(CreateView):
model = Video
fields = ('file',)

success_url = '/'
template_name = 'video_form.html'
Expand All @@ -23,7 +16,3 @@ def get_context_data(self, *args, **kwargs):
context = super(VideoFormView, self).get_context_data(*args, **kwargs)
context['videos'] = Video.objects.all()
return context

def form_valid(self, form):
form.save() # store video to database
return super(VideoFormView, self).form_valid(form)

0 comments on commit 3d44fee

Please sign in to comment.