mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	step="any" is required for non-integer values. See:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#step
Covers behaviour added in 7ec2a21be1.
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			698 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			698 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from django import forms
 | |
| from django.http import HttpResponse
 | |
| from django.template import Context, Template
 | |
| from django.views.generic.edit import UpdateView
 | |
| 
 | |
| from .models import Article
 | |
| 
 | |
| 
 | |
| class ArticleForm(forms.ModelForm):
 | |
|     content = forms.CharField(strip=False, widget=forms.Textarea)
 | |
| 
 | |
|     class Meta:
 | |
|         model = Article
 | |
|         fields = '__all__'
 | |
| 
 | |
| 
 | |
| class ArticleFormView(UpdateView):
 | |
|     model = Article
 | |
|     success_url = '/'
 | |
|     form_class = ArticleForm
 | |
| 
 | |
| 
 | |
| 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))
 |