Issue
Is there any way to reduce the size of the description box used below? I used it on a HTML template under a django project when I rendered the page the description box was huge.
<div class="container-fluid">
<div class="card-body">
<form action="{% url 'create_post' pk=classroom.id %}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group">
{{ post_form.title|attr:"class:form-control"|attr:"placeholder:Title"}}
</div>
<div class="container">
{{ post_form.description|attr:"class:form-control"|attr:"placeholder:Description" }}
</div>
<button type = "submit" class="btn btn-sm btn-primary m-1 pl-3 pr-3 float-right">
Post
</button>
<button id = "cancel-post" class="btn btn-sm btn-outline-dark m-1 float-right">
Cancel
</button>
</form>
</div>
</div>
Solution
try this
{{ post_form.description|attr:"class:form-control"|attr:"placeholder:Description"|attr:"rows:4"}}
https://pypi.org/project/django-widget-tweaks/
https://github.com/jazzband/django-widget-tweaks#attr
{% load widget_tweaks %}
<!-- add/change several attributes -->
{{ form.text|attr:"rows:20"|attr:"cols:20"|attr:"title:Hello, world!" }}
Answered By - rahul.m
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.