On Mon, Apr 14, 2008 at 11:58 AM, e <[EMAIL PROTECTED]> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---