Reputation: 793
This is a time critical bug otherwise I wouldn't have posted here and it's also my very first try with django and python so consider accordingly .
I am getting error
%o format: a number is required, not str
in my django app . The place where it shows error :(I am trying to create a message string)
msg_donor = 'Dear %s,\nThank you for contributing to %s \'s fundraising campaign
on Milaap.org. You\'ve made our day.\nRemember, since this is a loan, and not
donation, 100% of your money will come back to you!\nYou will shortly receive
your milaap login details. You can check who your money has gone to and track
your repayments through your account. Be sure to sign up and check your account
regularly for updates.\n\n%s' % (d.name, c.fundraiser_name, regardsStr)
I haven't written any %o in my application andI am wondering how this error can be produced ??
Upvotes: 0
Views: 202
Reputation: 92569
The problem is being cause by a stray %
in your string at: 100%
When you do string formatting, you have to make sure to escape literal % by doing %%
Try this:
msg_donor = """Dear %s,\nThank you for contributing to %s's fundraising campaign
on Milaap.org. You've made our day.\nRemember, since this is a loan, and not
donation, 100%% of your money will come back to you!\nYou will shortly receive
your milaap login details. You can check who your money has gone to and track
your repayments through your account. Be sure to sign up and check your account
regularly for updates.\n\n%s""" % (d.name, c.fundraiser_name, regardsStr)
Upvotes: 0
Reputation: 992937
You have 100% of your money
in your string. %
is a formatting character. Use 100%% of your money
to put a literal %
in there.
(I'm sort of surprised that Python skipped over the space between %
and o
, but whatever.)
Upvotes: 1