# model.py from django.db import models class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) gender = models.CharField(max_length=1, choices=[('M', 'Male'),('F','Female')]) birthdate = models.DateField() # forms.py from django.forms import ModelForm, TextInput, ChoiceField, Select from myapp.models import Person # change myapp for you app class PersonForm(ModelForm): gender = ChoiceFields( label='gender', choices=[('M', 'Male'),('F','Female')], widget=Select(attrs={'class': 'form-control'}) ) class Meta: model = Person fields = '__all__' widgets = { 'first_name': TextInput(attrs={'class': 'form-control'}), 'last_name': TextInput(attrs={'class': 'form-control'}), 'birthdate': TextInput(attrs={'class': 'form-control'}) } # generic-form.html
# view.py from django.core.urlresolvers import reverse_lazy from django.contrib.messages.views import SuccessMessageMixin from django.views.generic import CreateView from myapp.models import Person from myapp.forms import PersonForm class PersonCreate(SuccessMessageMixin, CreateView): model = Person form_class = PersonForm template = 'generic-form.html' success_url = reverse_lazy('url_to_success') # Change for you url success success_message = 'message_to_success' # Change for you message success