Traceback

string indices must be integers, not str

Request Method:         POST
Request URL:    http://newrutherford.paston2.webfactional.com/question/
Django Version:         1.3.1
Exception Type:         TypeError
Exception Value:        

string indices must be integers, not str

Exception Location: 
/home/paston2/webapps/newrutherford/newrutherford/question/views.py in
question, line 31
Python Executable:      /usr/local/bin/python
Python Version:         2.7.1
Python Path:    

['/home/paston2/webapps/newrutherford',
 '/home/paston2/webapps/newrutherford/newrutherford',
 '/home/paston2/webapps/newrutherford/newrutherford/paston_stuff',
 '/home/paston2/webapps/newrutherford/lib/python2.7',
 '/home/paston2/webapps/newrutherford',
 '/home/paston2/webapps/newrutherford/lib/python2.7',
 '/usr/local/lib/python27.zip',
 '/usr/local/lib/python2.7',
 '/usr/local/lib/python2.7/plat-linux2',
 '/usr/local/lib/python2.7/lib-tk',
 '/usr/local/lib/python2.7/lib-old',
 '/usr/local/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/site-packages',
 '/usr/local/lib/python2.7/site-packages/PIL']

Server time:    Mon, 21 Nov 2011 17:34:28 +0000
Traceback Switch to copy-and-paste view

   
/home/paston2/webapps/newrutherford/lib/python2.7/django/core/handlers/base.py
in get_response

                                response = callback(request, *callback_args,
**callback_kwargs)

        ...
    ▶ Local vars
    /home/paston2/webapps/newrutherford/newrutherford/question/views.py in
question

                    send_mail(settings.EMAIL_SUBJECT_PREFIX +"Email from the
question form", msg_header+msg_middle, settings.DEFAULT_FROM_EMAIL
[settings.CONTACT_EMAIL_TO], fail_silently=False)

        ...
    ▶ Local vars 

---------------------------------------------------------------------------------------------



MikeKJ wrote:
> 
> 1st time I have hit this and I am confused the subject error is returned
> as in the send_mail line
> all the fields in the model are either CharField or TextField
> 
> settings.py 
> 
> DEFAULT_FROM_EMAIL = '[email protected]'     ---- valid email address
> CONTACT_EMAIL_TO = '[email protected]'        ---- valid email address
> 
> views.py
> 
> class QuestionForm(ModelForm):
>     class Meta:
>         model = AskQuestion
> 
> def question(request):
>     if request.POST:
>         form = QuestionForm(request.POST)
>         if form.is_valid():
>             name = form.cleaned_data['name']
>             telephone = form.cleaned_data['telephone']
>             email = form.cleaned_data['email']
>             question = form.cleaned_data['question']
>             new = form.save()
>             msg_header = "A Question has been asked.\n\n"
>             msg_middle = "Name: %s\n\n" % form.cleaned_data['name']
>             msg_middle += "Telephone: %s\n\n" %
> form.cleaned_data['telephone']
>             msg_middle += "Email: %s\n\n" % form.cleaned_data['email']
>             msg_middle += "Question: %s\n\n" %
> form.cleaned_data['question']
>             send_mail(settings.EMAIL_SUBJECT_PREFIX +"Email from the
> question form", msg_header+msg_middle, settings.DEFAULT_FROM_EMAIL
> [settings.CONTACT_EMAIL_TO], fail_silently=False)
>             return HttpResponseRedirect('/question-response/')
>         else:
>             form = QuestionForm(request.POST)
>     else:
>         form = QuestionForm()
>     try:
>         exsp = SmartPage.objects.get(slug='question-form')
>     except SmartPage.DoesNotExist:
>         exsp = None
>     return render_to_repsonse("index.html", {'form': form, 'exsp': exsp,},
> context_instance=RequestContext(request))
> 
> 
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/string-indices-must-be-integers%2C-not-str-tp32871097p32871155.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
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.

Reply via email to