2017-12-30 32 views
0

TextField 열에 바삭한 양식이 배치 된 텍스트 상자가 너무 커서 내 화면이 너무 커서 화면 공간이 너무 많이 차지합니다. 원하는 경우 하단 프레임 선을 드래그하여 높이를 조정할 수 있지만 최소 크기가 너무 높습니다. 기본 높이를 4 줄 정도로하고 싶습니다.Django 싱싱 폼을 사용하는 경우 TextField의 텍스트 상자를 축소하는 방법은 무엇입니까?

나는 관련 게시물을 가지고 몇 가지 아이디어를 시도했지만 아무 것도 효과가 없었습니다. 텍스트 상자는 여전히 같은 높이로 키가 너무 큽니다.

class Brand(models.Model): 
    cTitle   = models.CharField(
         'brand name', max_length = 48, db_index = True) 
    bWanted   = models.BooleanField(
         'want anything from this brand?', default = True) 
    bAllOfInterest = models.BooleanField(
         'want everything from this brand?', default = True) 
    cLookFor  = models.TextField(
         'Considered a hit if this text is found ' 
         '(each line evaluated separately, ' 
         'put different look for tests on different lines)', 
         null=True, blank = True) 
    iStars   = IntegerRangeField(
         'desireability, 10 star brand is most desireable', 
         min_value = 0, max_value = 10, default = 5) 
    cComment  = models.TextField('comments', null = True, blank = True) 
    cNationality = CountryField("nationality", null = True) 
    cExcludeIf  = models.TextField(
         'Not a hit if this text is found ' 
         '(each line evaluated separately, ' 
         'put different exclude tests on different lines)', 
         null=True, blank = True) 
    iLegacyKey  = models.PositiveIntegerField('legacy key', null = True) 
    tLegacyCreate = models.DateTimeField('legacy row created on', 
         null=True, blank = True) 
    tLegacyModify = models.DateTimeField('legacy row updated on', 
         null=True, blank = True) 
    iUser   = models.ForeignKey(User, verbose_name = 'Owner', 
         on_delete=models.CASCADE) 
    tCreate   = models.DateTimeField('created on', auto_now_add= True) 
    tModify   = models.DateTimeField('updated on', auto_now = True) 
    # 

    def __str__(self): 
     return self.cTitle 

    class Meta(): 
     verbose_name_plural = 'brands' 
     ordering   = ('cTitle',) 
     db_table   = verbose_name_plural 

만이 필드를 양식에 있습니다 : :

tModelFields = (
    'cTitle', 
    'bWanted', 
    'bAllOfInterest', 
    'cLookFor', 
    'iStars', 
    'cComment', 
    'cNationality', 
    'cExcludeIf') 

지침 주시면 감사하겠습니다 여기

는 내가 지금 일하고 모델입니다.

+0

Field('cExcludeIf', rows='4') 당신이 내가 입력을 주셔서 감사합니다 해당 필드 –

답변

0

설명서에 따라 crispy_forms을 사용하고 있으므로 Layouts을 사용하여 템플릿에 추가 할 필드의 "요소"속성을 정의 할 수 있습니다 (as it is explained here in the documentation).

+0

에 대한 귀하의'models.py'에 주어진 것을 저를 공유 할 수 있습니다

은이 경우는 다음과 같이 될 것이다. 나는 그것을 시도했다. 필드 ('cExcludeIf', rows = '2')를 설정했으나 페이지의 텍스트 상자는 여전히 10 라인 높습니다. –