Form and ModelForm
.order_by()
.order_by()articles = Article.objects.order_by('-pk')ModelForm
ModelForm μ μνκΈ°
from django import forms
from .models import Article
class ArticleForm(forms.ModelForm):
title = forms.CharField(
max_length=100,
label='Title',
help_text='Your title must be no more than 100 characters in length',
widget=forms.TextInput(
attrs={
'class':'my_input',
'placeholder': "What's on your mind?"
}
)
)
content = forms.CharField(
label='Content',
help_text='Jot down random musings and thoughts',
widget=forms.Textarea(
attrs={
'row':5,
'col':50,
}
)
)
class Meta:
model = Article
# λ€ λλ €λ°μ
fields = '__all__'Viewμμ ModelFrom νμ©
ModelFrom νμ©request.resolver_match.url_name μΌλ‘ 쑰건μ λ°λ₯Έ μ²λ¦¬
request.resolver_match.url_name μΌλ‘ 쑰건μ λ°λ₯Έ μ²λ¦¬loop or bootstrap4 νμ©νμ¬ μΆλ ₯νκΈ°
loop or bootstrap4 νμ©νμ¬ μΆλ ₯νκΈ°Looping over the formβs fields
Form rendering options
Django Bootstrap μ¬μ©νκΈ°
Git
Last updated