django-forms

Django Form If condition in view.py with 2 instance

女生的网名这么多〃 提交于 2020-08-06 05:16:38
问题 TO SAVE DATA that is inputted in form in Django i tried tomake it like this I put this in my model.py class Item(models.Model): CATEGORY = ( ('Gudang Kering', 'Gudang Kering'), ('Gudang Basah','Gudang Basah'), ) name = models.CharField(max_length=200,null= True) stock = models.IntegerField(default='0', blank=False, null=True) category = models.CharField(max_length=200,null= True,choices=CATEGORY) reorderlevel = models.IntegerField(default='0', blank=False, null=True) maxreorderlevel = models

custom validation error for two fields unique together django

[亡魂溺海] 提交于 2020-07-23 06:15:18
问题 i want to write my own validation error , for two fields unique together class MyModel(models.Model): name = models.CharField(max_length=20) second_field = models.CharField(max_length=10) #others class Meta: unique_together = ('name','second_field') and my forms.py class MyModelForm(forms.ModelForm): class Meta: model = MyModel fields = '__all__' error_messages= {#how to write my own validation error whenever `name and second_field` are unique together }: how to write my own validation error

custom validation error for two fields unique together django

左心房为你撑大大i 提交于 2020-07-23 06:14:20
问题 i want to write my own validation error , for two fields unique together class MyModel(models.Model): name = models.CharField(max_length=20) second_field = models.CharField(max_length=10) #others class Meta: unique_together = ('name','second_field') and my forms.py class MyModelForm(forms.ModelForm): class Meta: model = MyModel fields = '__all__' error_messages= {#how to write my own validation error whenever `name and second_field` are unique together }: how to write my own validation error

custom validation error for two fields unique together django

蓝咒 提交于 2020-07-23 06:13:21
问题 i want to write my own validation error , for two fields unique together class MyModel(models.Model): name = models.CharField(max_length=20) second_field = models.CharField(max_length=10) #others class Meta: unique_together = ('name','second_field') and my forms.py class MyModelForm(forms.ModelForm): class Meta: model = MyModel fields = '__all__' error_messages= {#how to write my own validation error whenever `name and second_field` are unique together }: how to write my own validation error

class based view sum used for class based form validation (without forms.py)

匆匆过客 提交于 2020-07-22 05:19:55
问题 I have been working on this one for a few days and have re-worked how i'd like to handle this functionality on my fantasy sports website: Objective : limit the number of players allowed on a fantasy owner's roster. Django out-of-the-box User = Owner # models.py class Player(models.Model): player_full = models.CharField(max_length=50) player_owner = models.ForeignKey(User, blank=True, null=True, on_delete=models.SET_NULL) image = models.ImageField(default='default_player.jpg', upload_to=

class based view sum used for class based form validation (without forms.py)

孤人 提交于 2020-07-22 05:19:12
问题 I have been working on this one for a few days and have re-worked how i'd like to handle this functionality on my fantasy sports website: Objective : limit the number of players allowed on a fantasy owner's roster. Django out-of-the-box User = Owner # models.py class Player(models.Model): player_full = models.CharField(max_length=50) player_owner = models.ForeignKey(User, blank=True, null=True, on_delete=models.SET_NULL) image = models.ImageField(default='default_player.jpg', upload_to=

How to edit UserCreationForm password help text?

 ̄綄美尐妖づ 提交于 2020-07-21 03:24:32
问题 When I create a registration form that inherits from UserCreationForm , the text "Your password can't be too similar to your other personal information. Your password must contain at least 8 characters. Your password can't be a commonly used password. Your password can't be entirely numeric." appears under the password input fields and takes up quite a bit of space. Is there a way I can remove this? I know the username help text can be removed with: help_texts = { 'username': None } but help

How to edit UserCreationForm password help text?

纵然是瞬间 提交于 2020-07-21 03:23:18
问题 When I create a registration form that inherits from UserCreationForm , the text "Your password can't be too similar to your other personal information. Your password must contain at least 8 characters. Your password can't be a commonly used password. Your password can't be entirely numeric." appears under the password input fields and takes up quite a bit of space. Is there a way I can remove this? I know the username help text can be removed with: help_texts = { 'username': None } but help

Creating UpdateForm by using ModelForm in Django

青春壹個敷衍的年華 提交于 2020-07-21 03:22:51
问题 I have a Django application and I wanna create an update form with ModelForm but I have to get the fields parameter from user_profile model. So I have created my form and view such as below. forms.py; class UpdateForm(forms.ModelForm): class Meta: model = Data fields = [] def __init__(self, *args, **kwargs): input_choices = kwargs.pop('input_choices') super(UpdateForm, self).__init__(*args,**kwargs) self.fields = input_choices views.py; @login_required(login_url = "user:login") def updateData

Creating UpdateForm by using ModelForm in Django

送分小仙女□ 提交于 2020-07-21 03:20:07
问题 I have a Django application and I wanna create an update form with ModelForm but I have to get the fields parameter from user_profile model. So I have created my form and view such as below. forms.py; class UpdateForm(forms.ModelForm): class Meta: model = Data fields = [] def __init__(self, *args, **kwargs): input_choices = kwargs.pop('input_choices') super(UpdateForm, self).__init__(*args,**kwargs) self.fields = input_choices views.py; @login_required(login_url = "user:login") def updateData