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