django-forms

Why does my Django form keep saying “this field is required”

拥有回忆 提交于 2020-07-09 09:27:16
问题 Does anyone know why my form (filepicker) is constantly returning "this field is required" when it worked in a simpler version? My view is def add_attempt(request, m_id, a_id): template = loader.get_template('add_attempt.html') if request.method == 'POST': import pprint pprint.pprint(request.POST) pprint.pprint(request.FILES) form = UploadAttemptForm(data=request.POST, files=request.FILES) if form.is_valid(): form.instance.pub_date = datetime.datetime.now() form.instance.user_id = request

Nested django form for foreignkey model

Deadly 提交于 2020-07-09 05:27:21
问题 I have two models that look something like class Address(models.Model): line1 = models.CharField(max_length=128, help_text="Address Line 1") city = models.CharField(max_length=128) state = USStateField() zipcode = USZipCodeField() class Company(models.Model): name = models.CharField(max_length=100) address = models.ForeignKey('Address', on_delete=models.PROTECT) And I would like to generate a form that looks something like below, although I have no idea how to save the address from within a

Django: django-autocomplete-light does not work properly

回眸只為那壹抹淺笑 提交于 2020-07-08 10:51:32
问题 I'm using django-autocomplete-light in django 1.8. But I don't know how to use it in forms.py . Instead of autocomplete field I see a select field. I followed the instructions from here. In models.py I have: class icd_10(models.Model): id = models.IntegerField(unique=True,primary_key=True,null=False,blank=False) icd_10_desc = models.CharField('ICD-10 description',max_length=80,null=True,blank=True) icd_10_code = models.CharField('ICD-10 code',max_length=10,null=True,blank=True) def __str__

Django: django-autocomplete-light does not work properly

拈花ヽ惹草 提交于 2020-07-08 10:51:06
问题 I'm using django-autocomplete-light in django 1.8. But I don't know how to use it in forms.py . Instead of autocomplete field I see a select field. I followed the instructions from here. In models.py I have: class icd_10(models.Model): id = models.IntegerField(unique=True,primary_key=True,null=False,blank=False) icd_10_desc = models.CharField('ICD-10 description',max_length=80,null=True,blank=True) icd_10_code = models.CharField('ICD-10 code',max_length=10,null=True,blank=True) def __str__

Creating editable HTML tables with Django

倾然丶 夕夏残阳落幕 提交于 2020-07-06 20:07:21
问题 I'm trying to create a Django app where the user can make a list of movies. Each time the user logs in, their list of movies will be presented to them in a table. The table will have three columns: one for the movie's name, one for the genre, and another that will contain delete buttons that will allow the user to delete the row corresponding to the button. The user can add rows to the table by filling in a textbox with the name of the movie, and selecting a genre from a drop down menu, and

Creating editable HTML tables with Django

给你一囗甜甜゛ 提交于 2020-07-06 20:04:20
问题 I'm trying to create a Django app where the user can make a list of movies. Each time the user logs in, their list of movies will be presented to them in a table. The table will have three columns: one for the movie's name, one for the genre, and another that will contain delete buttons that will allow the user to delete the row corresponding to the button. The user can add rows to the table by filling in a textbox with the name of the movie, and selecting a genre from a drop down menu, and

Django modelform how to add a confirm password field?

坚强是说给别人听的谎言 提交于 2020-07-04 07:44:19
问题 Here I need to add an extra confirmation password in my form.I used Django's modelform. I also need to validate both passwords. It must raise a validation error if password1 != password2 . Here is my forms.py: class UserForm(forms.ModelForm): password=forms.CharField(widget=forms.PasswordInput()) class Meta: model=User fields=('username','email','password') class UserProfileForm(forms.ModelForm): YESNO_CHOICES = (('male', 'male'), ('female', 'female')) sex = forms.TypedChoiceField(choices

Django modelform how to add a confirm password field?

允我心安 提交于 2020-07-04 07:43:49
问题 Here I need to add an extra confirmation password in my form.I used Django's modelform. I also need to validate both passwords. It must raise a validation error if password1 != password2 . Here is my forms.py: class UserForm(forms.ModelForm): password=forms.CharField(widget=forms.PasswordInput()) class Meta: model=User fields=('username','email','password') class UserProfileForm(forms.ModelForm): YESNO_CHOICES = (('male', 'male'), ('female', 'female')) sex = forms.TypedChoiceField(choices

Django modelform how to add a confirm password field?

我怕爱的太早我们不能终老 提交于 2020-07-04 07:43:05
问题 Here I need to add an extra confirmation password in my form.I used Django's modelform. I also need to validate both passwords. It must raise a validation error if password1 != password2 . Here is my forms.py: class UserForm(forms.ModelForm): password=forms.CharField(widget=forms.PasswordInput()) class Meta: model=User fields=('username','email','password') class UserProfileForm(forms.ModelForm): YESNO_CHOICES = (('male', 'male'), ('female', 'female')) sex = forms.TypedChoiceField(choices

inline formset only save the last form

只愿长相守 提交于 2020-07-04 03:46:16
问题 i tried many ways and searched alot(googled) but no one worked for me . whenever i save my inlineformset it only save the last form , my models.py class Book(models.Model): book = models.CharField(max_length=20,unique=True) author = models.ForeignKey(Author,on_delete=models.CASCADE) class Author(models.Model): author = models.CharField(max_length=30,unique=True) count = models.IntegerField() this is my forms.py class AuthorForm(ModelForm): class Meta: model = Author fields = ['author','count'