Re: string indices must be integers, not str

2011-11-21 Thread MikeKJ

Yep, you found it  a missing comma.cheers



Ian Clelland-2 wrote:
> 
> On Mon, Nov 21, 2011 at 9:37 AM, MikeKJ <mike.jo...@paston.co.uk> wrote:
> 
>>
>> 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
>>
> 
> Line 31 is the problem --- and we can't tell which one is line 31 from the
> code you've posted here.
> 
> This line looks wrong to me:
> 
> 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)
> 
> 
> Maybe it's a word-wrapping issue, but
> "settings.DEFAULT_FROM_EMAIL[settings.CONTACT_EMAIL_TO]"
> looks like you're trying to use a string to index into another string
> variable.
> 
> Ian
> 
> -- 
> Regards,
> Ian Clelland
> <clell...@gmail.com>
> 
> -- 
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/string-indices-must-be-integers%2C-not-str-tp32871097p32871170.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 django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: string indices must be integers, not str

2011-11-21 Thread Ian Clelland
On Mon, Nov 21, 2011 at 9:37 AM, MikeKJ <mike.jo...@paston.co.uk> wrote:

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

Line 31 is the problem --- and we can't tell which one is line 31 from the
code you've posted here.

This line looks wrong to me:

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)


Maybe it's a word-wrapping issue, but
"settings.DEFAULT_FROM_EMAIL[settings.CONTACT_EMAIL_TO]"
looks like you're trying to use a string to index into another string
variable.

Ian

-- 
Regards,
Ian Clelland
<clell...@gmail.com>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: string indices must be integers, not str

2011-11-21 Thread MikeKJ

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 +
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 = 'x...@.co.uk'  valid email address
> CONTACT_EMAIL_TO = 'x...@.co.uk' 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 django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: string indices must be integers, not str

2011-11-21 Thread Andre Terra
Please paste your full traceback every time you are asking for help with
debugging.


Cheers,
AT

On Mon, Nov 21, 2011 at 3:10 PM, 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 = 'x...@.co.uk'  valid email address
> CONTACT_EMAIL_TO = 'x...@.co.uk' 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-tp32871097p32871097.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 django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



string indices must be integers, not str

2011-11-21 Thread MikeKJ

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 = 'x...@.co.uk'  valid email address
CONTACT_EMAIL_TO = 'x...@.co.uk' 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-tp32871097p32871097.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 django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



string indices must be integers, not str

2011-11-21 Thread MikeKJ

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 = 'x...@.co.uk'  valid email address
CONTACT_EMAIL_TO = 'x...@.co.uk' 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-tp32871095p32871095.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 django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.