Answer the question
In order to leave comments, you need to log in
Form output in Django?
Made a shape
from django import forms
from .models import Post
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ('title', 'text',)
<h1>Новий пост</h1>
<form method="POST" class="post-form">{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="save btn btn-default">Save</button>
</form>
<div class="col-md-12 col-lg-8 main-content">
<form method="POST">{% csrf_token %}
<div class="row">
<div class="col-md-4 form-group">
<label for="name">Заголовок</label>
<input type="text" id="name" class="form-control " >
</div>
</div>
<div class="row">
<div class="col-md-12 form-group">
<label for="message">Текст</label>
<textarea name="message" id="message" class="form-control " cols="30" rows="8"></textarea>
</div>
</div>
<div class="row">
<div class="col-md-6 form-group">
<input type="submit" value="Опубликовать" class="btn btn-primary">
</div>
</div>
</form>
</div>
Answer the question
In order to leave comments, you need to log in
Or you can use https://github.com/jazzband/django-widget-tweaks
and don't mix python code with css and html.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question