On Tue, Apr 15, 2008 at 2:19 PM, e <erict
...@gmail.com> wrote:
> Is this worthy of submitting a ticket to fix the documentation for?
I'd say so. Near as I can tell if you cut & paste the example from the
documentation it doesn't work. That seems wrong, and worth fixing.
> On Apr 14, 2:10 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:
> > On Mon, Apr 14, 2008 at 11:58 AM, e <erict...@gmail.com> wrote:
> > > I have a form set up and all working, its basically straight out of
> > > the Form Processing chapter of the django book:
> > > class ContactForm(forms.Form):
> > > email = forms.EmailField(required=True)
> > > message = forms.CharField()
> > > phone_number = forms.CharField()
> > > def contact(request):
> > > form = ContactForm()
> > > return render_to_response('contact.html', {'form': form})
> > > Now this works just fine, but I want to use
> > > django.contrib.localflavor.us.forms.USPhoneNumberFIeld instead of the
> > > CharField for the phone_number. When I replace it with this line:
> > > phone_number = us.forms.USPhoneNumberField(max_length=100)
> > > I get this error:
> > > ViewDoesNotExist: Tried contact in module mysite.contact.views. Error
> > > was: 'module' object has no attribute 'forms'
> > > What am I doing wrong?
> > I'm assuming you have:
> > from django.contrib.localflavor import us
> > somewhere before you try to define phone_number as us.forms.USPhone...
> > Instead try:
> > from django.contrib.localflavor.us.forms import USPhoneNumberField
> > phone_number = USPhoneNumberField()
> > This works for me. I don't know why the documentation (
> http://www.djangoproject.com/documentation/localflavor/) shows an example
> > using the first kind of import, since it does not appear that things are
> set
> > up for that to work.
> > Karen