Yash Marmat
Yash Marmat

Reputation: 1197

How to increase the column size in django template?

I can strech(adjust) rows through cursor but problem is i cant do the same for column (as shown in picture)

here is the code i used:

{% extends "base.html" %}


{% block content %}

<h2>New Blog</h2><br>

<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" class="btn btn-success ml-2" value="save">
<a class="btn btn-primary" href="{% url 'blog_list' %}" role="button">Cancel</a>
</form>

{% endblock content %}

new blog

here are my views.py and models.py files

https://github.com/YashMarmat/personal-documnets-.git

Upvotes: 0

Views: 276

Answers (1)

m51
m51

Reputation: 2010

Create Forms.py file in your app, then add a custom model in it as shown below:

from django.forms import ModelForm, Textarea

class BlogCreateForm(ModelForm):
    class Meta:
        model = Blog
        fields = ('title', 'body', 'author')
        widgets = {
            'body': Textarea(attrs={'cols': 80, 'rows': 20}),
        }

Replace the code present in views.py with the below one:

class BlogCreate(LoginRequiredMixin, CreateView):
    model = Blog
    template_name = "blog_new.html"
    form_class = BlogCreateForm
    success_url = reverse_lazy("blog_list")
    login_url = 'login'

Upvotes: 1

Related Questions