Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 12th, 2012  |  syntax: Python  |  size: 0.82 KB  |  views: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ##################### in fields.py #####################
  2. from django import forms
  3.  
  4. class DomainField(forms.CharField):
  5.    
  6.     def clean(self, value):
  7.         # Anything can go here
  8.         return value
  9.  
  10.  
  11. ##################### in forms.py #####################
  12. from django import forms
  13. from fields import DomainField
  14.  
  15. class TestForm(forms.Form):
  16.     # should be DomainField(), not forms.DomainField()
  17.     domain = forms.DomainField(max_length=100, required=False)
  18.  
  19.  
  20. ##################### in views.py #####################
  21. from django.http import HttpResponse
  22. from viewerrorapp.forms import TestForm
  23.  
  24. # Create your views here.
  25. def home(request):
  26.     form = TestForm()
  27.     return HttpResponse("I never get here :(")
  28.  
  29. def hom2(request)
  30.     return HttpREsponse("Neither do I and I have nothing to do with the form!")
clone this paste RAW Paste Data