Question about widget in Django form

Asked 2 years ago, Updated 2 years ago, 51 views

I wrote it on models.py as follows.

 class register(models.Model): #membership form
        tel=models.CharField (max_length=30, null=True,blank=True) #Contact

I wrote it on form.py as follows.

class RegistrationForm(UserCreationForm):
    tel=forms.CharField(widget=forms.TextInput (attrs=dict (required=True, max_length=30), label=_("Contact"))

That's what it says. Django admin saves it even if you don't put in the value, but I don't think it's in the form. Is there any way? And

class ApplyForm(forms.ModelForm):
 applydate=forms.DateField (widget=SelectDateWidget, initial=datetime.date.today, label=_("date"))
 applytime=forms.TimeField (label=_("Application Time")  

As I fill out the form below, is there any other form? Please recommend.

django

2022-09-22 21:38

1 Answers

Tel is set as the required input in the Registration Form. Replace required = True with False.

In the case of ApplyForm, what form does it mean if it's a different form? If you want to modify the shape, you can modify the CSS.


2022-09-22 21:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.