Home > Enterprise >  how to reduce Django text field height
how to reduce Django text field height

Time:09-23

I am Creating Ordering Form Where I need to Add Location in TextField. I Want To Know How To Reduce TextField Height

class Lead(models.Model):
    first_name = models.CharField(max_length=20)
    last_name = models.CharField(max_length=20)
    organisation = models.ForeignKey(UserProfile,null=True, blank=True, on_delete=models.SET_NULL)
    foodlancer = models.ForeignKey("Agent", on_delete=models.CASCADE)
    catagory = models.ForeignKey("Catagory", related_name="leads" ,null=True, blank=True, on_delete=models.SET_NULL)
    date_added = models.DateTimeField(auto_now_add=True)
    phone_number = models.CharField(max_length=20)
    email = models.EmailField()
    location = models.TextField(max_length=250)
    persons = models.IntegerField(max_length=100)

Right Now It's Just Like That:

And I Want To Do Like That:

CodePudding user response:

class LeadForm(forms.ModelForm):
    class Meta:
        model = Lead
        widgets = {
          'location ': forms.Textarea(attrs={'rows':row_number, 'cols':col_number}),
        }
  • Related