Skip to content

Commit d704f34

Browse files
author
Max Goodridge
committed
Added custom attributes to form element
1 parent 3c85891 commit d704f34

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

home/forms.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33

44

55
class HomeForm(forms.ModelForm):
6-
post = forms.CharField()
6+
post = forms.CharField(widget=forms.TextInput(
7+
attrs={
8+
'class': 'form-control',
9+
'placeholder': 'Write a post...'
10+
}
11+
))
712

813
class Meta:
914
model = Post

home/templates/home/home.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<h1>Home</h1>
66
<form method="post">
77
{% csrf_token %}
8-
{{ form.as_p }}
8+
{{ form.post }}
9+
<br>
910
<button type="submit">Submit</button>
1011
</form>
1112
<h2>{{ text }}</h2>

0 commit comments

Comments
 (0)