mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	This also updates all dependent functionality, including modelform_factory and modelformset_factory, and the generic views `ModelFormMixin`, `CreateView` and `UpdateView` which gain a new `fields` attribute.
		
			
				
	
	
		
			20 lines
		
	
	
		
			377 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			377 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from __future__ import absolute_import
 | |
| 
 | |
| from django import forms
 | |
| 
 | |
| from .models import Author
 | |
| 
 | |
| 
 | |
| class AuthorForm(forms.ModelForm):
 | |
|     name = forms.CharField()
 | |
|     slug = forms.SlugField()
 | |
| 
 | |
|     class Meta:
 | |
|         model = Author
 | |
|         fields = ['name', 'slug']
 | |
| 
 | |
| 
 | |
| class ContactForm(forms.Form):
 | |
|     name = forms.CharField()
 | |
|     message = forms.CharField(widget=forms.Textarea)
 |