django-forms

how to produce <span> instead of <li> tag

跟風遠走 提交于 2019-12-24 06:38:09
问题 forms.py class ZergitForm(forms.Form): zerg_selection = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(),required=False) views.py def feeds(request): if request.method == 'POST': zergform = ZergitForm(request.POST) """""""" some other logic comes here """""""" selection = ZergitForm(zerg_id) return render(request, 'feed_list.html',{'zerg_selection':zerg_selection}) feed_list.html {% for feed in selection.zerg_selection %} <span class="checkbox_select">{{ feed }}</span> {%

django modelformset_factory doesn't include actual forms

不问归期 提交于 2019-12-24 06:25:44
问题 I've been trying to follow tutorials and other SO questions and have a modelformset_factory that's displaying a list of what looks like forms in the html, but it turns out they're not actual forms. html that gets displayed: <div ='container'> <div class='row'><tr><th><label for="id_form-0-config_key">Config key:</label></th><td><input id="id_form-0-config_key" maxlength="63" name="form-0-config_key" type="text" value="ClientMustVerify" /></td></tr> <tr><th><label for="id_form-0-config_value"

inline formset factory update view

删除回忆录丶 提交于 2019-12-24 06:03:07
问题 i want to get in inline formset factory in update view extra=0 , if it have more than 1 contact. So this is my code forms.py class ShopForm(ModelForm): class Meta: model = Shop exclude = ['user', 'slug', 'counter'] def __init__(self, *args, **kwargs): super(ShopForm, self).__init__(*args, **kwargs) for field in iter(self.fields): self.fields[field].widget.attrs.update({ 'class': 'form-control' }) def clean_logo(self): logo = self.cleaned_data['logo'] if not logo: raise forms.ValidationError(

inline formset factory update view

試著忘記壹切 提交于 2019-12-24 06:02:19
问题 i want to get in inline formset factory in update view extra=0 , if it have more than 1 contact. So this is my code forms.py class ShopForm(ModelForm): class Meta: model = Shop exclude = ['user', 'slug', 'counter'] def __init__(self, *args, **kwargs): super(ShopForm, self).__init__(*args, **kwargs) for field in iter(self.fields): self.fields[field].widget.attrs.update({ 'class': 'form-control' }) def clean_logo(self): logo = self.cleaned_data['logo'] if not logo: raise forms.ValidationError(

Django formwizard with formsets and forms on same page

蹲街弑〆低调 提交于 2019-12-24 05:19:10
问题 I'm working with Django 1.4 FormWizard (specifically, NamedUrlFormWizard) first, the basics. i have a 3 step form wizard i'm building. The final outcome is along the lines of defining a template, and then choosing some people to use it, and then send them an email. Step 1 - enter in basic template data (name, description, etc) Step 2 - define a list of N fields, each with their own set of attributes but all identical in structure Step 3 - choose one or more users to email, AND customize the

Django's ClearableFileInput widget doesn't pass initial (“Currently”) value on submit

淺唱寂寞╮ 提交于 2019-12-24 04:14:05
问题 My basic goal is to create a form (using ModelForm ) prefilled with data from an existing database object, allow a user to modify those data, then save the submitted form as a new object. (Sort of a "Copy" then "Paste With Modifications" setup.) This works fine except with File Fields and the ClearableFileInput widget. The answers to questions like this, this, and this make it clear that file fields can't and shouldn't be populated with an initial value. The Django docs, however, on the

Django's ClearableFileInput widget doesn't pass initial (“Currently”) value on submit

怎甘沉沦 提交于 2019-12-24 04:13:05
问题 My basic goal is to create a form (using ModelForm ) prefilled with data from an existing database object, allow a user to modify those data, then save the submitted form as a new object. (Sort of a "Copy" then "Paste With Modifications" setup.) This works fine except with File Fields and the ClearableFileInput widget. The answers to questions like this, this, and this make it clear that file fields can't and shouldn't be populated with an initial value. The Django docs, however, on the

Adding profile picture to django user

女生的网名这么多〃 提交于 2019-12-24 03:53:32
问题 I'm trying to follow this post to associate a profile picture to a user in Django. I have the following model class MyUser(AbstractBaseUser): """ Custom user class. """ GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female'), ) email = models.EmailField('email address', unique=True, db_index=True) is_staff = models.BooleanField('is staff', default=False) first_name = models.TextField('first name', default=None, null=True) last_name = models.TextField('last name', default=None, null=True) date_of

Django - Changing inline formset textInput size attribute

纵然是瞬间 提交于 2019-12-24 03:41:14
问题 I have an inline formset that only has three fields: class Estimate_Product_Details(models.Model): proposalID = models.ForeignKey(Estimate_Construction, verbose_name='Proposal ID') CID = models.ForeignKey(Product, verbose_name = 'CID') qty = models.DecimalField(max_digits = 7, decimal_places = 2, verbose_name = 'Quantity') def __unicode__(self): return u'%s -- %s' % (self.proposalID, self.CID) I then create a form from that model: class Product_Form(ModelForm): class Meta: model = Estimate

Cleanup partly-uploaded files handled by TemporaryFileUploadHandler in Django

妖精的绣舞 提交于 2019-12-24 03:14:47
问题 I am using the TemporaryFileUploadHandler to upload files. If a user is uploading a large file and cancels the upload, the file remains in my temporary directory. Is there a way to trap a cancelled upload (connection reset before a file was fully uploaded) in order to cleanup these files? The only alternative I can think of is a cron job which looks at the temp directory and deletes files which have not been updates in some reasonable amount of time. 回答1: Not sure if it helps, but you may try