form_for_model

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from django.newforms import form_for_model
from muzx.news.models import Menu
def contact(request):
if request.method == 'POST':
form = form_for_model(Menu)(request.POST)
if form.is_valid():
form.save()
return render_to_response('detail.html',)
else:
form = form_for_model(Menu)()
return render_to_response('contact.html', {'form': form})