12345678910111213141516171819202122232425 |
- from django import forms
- from .models import Media, Thumbnail
- from .widgets import ThumbnailRadioSelect
- import os
- import logging
- logger = logging.getLogger('django')
- class MediaForm(forms.ModelForm):
- #delete = forms.BooleanField(required=False)
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.fields['poster'].choices = [(x.pk,os.path.basename(x.image.name),) for x in self.instance.thumbnail_set.all()]
- class Meta:
- model = Media
- fields = ('title', 'poster', 'tags', 'description')
- class UploadForm(forms.Form):
- chunked_upload = forms.FileField(label='Pick a file', widget=forms.ClearableFileInput(attrs={'multiple': True}))
|