Trying to follow along with the Form Tutorial on the Django site and
I'm running into a problem. I keep getting the error page 'module'
object has not attribute 'ContactForm', when I just simply copy and
pasted the code from the tutorial into my models.py. Here is my
source. I feel like it has something to do with my urls.py since I'm
trying to use the template system.
--------------------------------------------
Models.py
from django import forms
class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField()
sender = forms.EmailField()
cc_myself = forms.BooleanField(required=False)
----------------------------------------------------
urls.py
from django.conf.urls.defaults import *
from xxx django.contrib import admin
# Uncomment the next two lines to enable the admin:
#admin.autodiscover()
urlpatterns = patterns('xxx.register.views',
(r'^$', 'ContactForm'),
# Uncomment the next line to enable the admin:
#(r'^admin/(.*)', admin.site.root),
# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
)
----------------------------------------------------------------
views.py
def contact(request):
if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST
data
if form.is_valid(): # All validation rules pass
subject = form.cleaned_data['subject']
message = form.cleaned_data['message']
sender = form.cleaned_data['sender']
cc_myself = form.cleaned_data['cc_myself']
recipients = ['[EMAIL PROTECTED]']
if cc_myself:
recipients.append(sender)
from django.core.mail import send_mail
send_mail(subject, message, sender, recipients)
return HttpResponseRedirect('/thanks/')
else:
form = ContactForm()
return render_to_response('contact.html', {'form': form,})
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---