SHARE
TWEET

Untitled

a guest Jul 12th, 2012 30 Never
  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!")
RAW Paste Data
Top