-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test_proj): example for FormView, #10
- Loading branch information
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
CHANGELOG | ||
======= | ||
|
||
Unreleased | ||
---------- | ||
|
||
* Example for Form usage | ||
|
||
|
||
0.2 (21.01.2018) | ||
---------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<h1>Video Upload</h1> | ||
<form action="" method="post" enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
{{ form }} | ||
<input type="submit" value="Submit"> | ||
</form> | ||
|
||
<h2>Uploaded Videos</h2> | ||
{% for video in videos %} | ||
{{ video.file.name }} | ||
(Duration: {{ video.duration }}s, {{ video.width }}x{{ video.height }}) | ||
<br> | ||
{% endfor %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.views.generic import CreateView | ||
|
||
from video_encoding.fields import VideoField | ||
|
||
from .models import Video | ||
|
||
|
||
class VideoFormView(CreateView): | ||
model = Video | ||
fields = ('file',) | ||
|
||
success_url = '/' | ||
template_name = 'video_form.html' | ||
|
||
def get_context_data(self, *args, **kwargs): | ||
context = super(VideoFormView, self).get_context_data(*args, **kwargs) | ||
context['videos'] = Video.objects.all() | ||
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
from django.conf.urls import include, url | ||
from django.conf.urls import url | ||
from django.contrib import admin | ||
|
||
from .media_library.views import VideoFormView | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^admin/', include(admin.site.urls)), | ||
url(r'^admin/', admin.site.urls), | ||
url(r'^', VideoFormView.as_view()), | ||
] |