2015-07-05 01:24:28 +08:00
|
|
|
from django import forms
|
2022-02-03 15:33:26 +08:00
|
|
|
from django.http import HttpResponse
|
|
|
|
from django.template import Context, Template
|
2012-11-06 03:27:06 +08:00
|
|
|
from django.views.generic.edit import UpdateView
|
|
|
|
|
|
|
|
from .models import Article
|
|
|
|
|
|
|
|
|
2015-07-05 01:24:28 +08:00
|
|
|
class ArticleForm(forms.ModelForm):
|
|
|
|
content = forms.CharField(strip=False, widget=forms.Textarea)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Article
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
2012-11-06 03:27:06 +08:00
|
|
|
class ArticleFormView(UpdateView):
|
|
|
|
model = Article
|
|
|
|
success_url = "/"
|
2015-07-05 01:24:28 +08:00
|
|
|
form_class = ArticleForm
|
2022-02-03 15:33:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
def form_view(request):
|
|
|
|
class Form(forms.Form):
|
|
|
|
number = forms.FloatField()
|
|
|
|
|
|
|
|
template = Template("<html>{{ form }}</html>")
|
|
|
|
context = Context({"form": Form()})
|
|
|
|
return HttpResponse(template.render(context))
|