diff --git a/app/forms.py b/app/forms.py index a9fb6bf4535c1db90dfb537c7cb1223ad3db06a5..e3032496727d46e129cd23af793be5b956b7df07 100644 --- a/app/forms.py +++ b/app/forms.py @@ -1,10 +1,14 @@ from django import forms -from app.models import Materi +from app.models import Materi,Category from authentication.models import User class UploadMateriForm(forms.ModelForm): + + categories = forms.ModelMultipleChoiceField(queryset=Category.objects.all(),widget=forms.CheckboxSelectMultiple(attrs={'style' : 'column-count:2'}),required=True) + #categories.widget.attrs["style"] = "column-count:2" + class Meta: model = Materi fields = ["title", "author", "publisher", @@ -13,7 +17,11 @@ class UploadMateriForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(UploadMateriForm, self).__init__(*args, **kwargs) for field_name, field in self.fields.items(): + if (field_name == "categories"): + continue field.widget.attrs["class"] = "form-control" + self.fields['categories'].widget.attrs.update({'class' : "native"}) + class SuntingProfilForm(forms.ModelForm): diff --git a/app/templates/unggah.html b/app/templates/unggah.html index df06d7af66cae41a5a887a1f79370cececbb3faa..d9154e94afba197ffd85d44e509a256d53f50003 100644 --- a/app/templates/unggah.html +++ b/app/templates/unggah.html @@ -3,6 +3,23 @@ <!DOCTYPE html> <html lang="en"> +<style> + ul{margin:0; padding:0;} + + .native { + -webkit-column-width: 200px; + -moz-column-width: 200px; + -o-column-width: 200px; + -ms-column-width: 200px; + column-width: 200px; + + -webkit-column-rule-style: solid; + -moz-column-rule-style: solid; + -o-column-rule-style: solid; + -ms-column-rule-style: solid; + column-rule-style: solid; + } +</style> <head> <meta charset="utf-8">