Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 8th, 2012  |  syntax: Python  |  size: 0.39 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # FORMS.PY
  2. from django import forms
  3. from django.forms import ModelForm
  4. from models import *
  5.  
  6. class CommentForm(forms.ModelForm):
  7.         class Meta:
  8.                 fields = ('author', 'email', 'entry', 'text')
  9.                 model = Comment
  10.  
  11. # VIEWS.PY
  12. def entry(request, entry_id):
  13.         if request.method == 'POST':
  14.                 form = CommentForm(data=request.POST)
  15.                 if form.is_valid():
  16.                         form.save()
  17.         else:
  18.                 form = CommentForm()