How to add widget in django web blog -
i learning django framework using djangogirls tutorial, reading tutorial making blog want add popular blog post show widget in blog unable it, how can , add widget in myblog . please details.
thanks lot rana
this rather generic approach.i hope helps.
a widget django’s representation of html input element. widget handles rendering of html, , extraction of data get/post dictionary corresponds widget.
you can specify widget :
from django import forms class commentform(forms.form): name = forms.charfield() url = forms.urlfield() comment = forms.charfield(widget=forms.textarea)
many widgets have optional arguments; can set when defining widget on field. in following example, years attribute set selectdatewidget:
from django import forms birth_year_choices = ('1980', '1981', '1982') favorite_colors_choices = ( ('blue', 'blue'), ('green', 'green'), ('black', 'black'), ) class simpleform(forms.form): birth_year = forms.datefield(widget=forms.selectdatewidget(years=birth_year_choices)) favorite_colors = forms.multiplechoicefield(required=false, widget=forms.checkboxselectmultiple, choices=favorite_colors_choices)
Comments
Post a Comment