Django18初体验
1066 浏览 5 years, 11 months
11.11 ModelForm
版权声明: 转载请注明出处 http://www.codingsoho.com/Newsletter下面添加文件forms.py
from django import forms
from .models import SignUp
class SignUpForm(forms.ModelForm):
class Meta:
model = SignUp
fields = ['full_name', 'email']
### exclude = ['full_name']
Modify admin.py
from django.contrib import admin
# Register your models here.
from .forms import SignUpForm
from .models import SignUp
class SignUpAdmin(admin.ModelAdmin):
list_display = ["__unicode__", "timestamp", "updated"]
form = SignUpForm
# class Meta:
# model = SignUp
admin.site.register(SignUp, SignUpAdmin)