daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def get_opinion(request):
  2.  
  3.     if request.method == 'POST':
  4.         f = OpinionForm(request.POST)
  5.         if form_is_blank(f):
  6.             return HttpResponseRedirect(reverse('thank_you_anyway'))
  7.         elif f.is_valid():
  8.             #Process here
  9.             return HttpResponseRedirect(reverse('thanks_for_participating'))
  10.     else:
  11.         initial = {'weekday': date.today().strftime('%A')}
  12.         f = OpinionForm(initial=initial)
  13.  
  14.     return render_to_response(
  15.         'get_opinion.html',
  16.         {'form': f,},
  17.         RequestContext(request)
  18.     )
  19.    
  20. >>> f = MyForm({})
  21. >>> f.has_changed()
  22. False
  23. >>> f = MyForm({})
  24. >>> f.has_changed()
  25. False
  26. >>> f = MyForm({'name': 'test'})
  27. >>> f.has_changed()
  28. True
  29. >>> f = MyForm({'name': 'test'}, initial={'name': 'test'})
  30. >>> f.has_changed()
  31. False
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top