login community faq

I am trying to use the admin interface for Django to add data to a sqlite database. The input is based on the following model:

1
2
3
4
class ShuttleStop(models.Model):
    name = models.CharField(max_length='35')
    latitude = models.DecimalField(max_digits='16', decimal_places='13')
    longitude = models.DecimalField(max_digits='16', decimal_places='13')

My input into the "Add Shuttle Stop" screen is the following (as shown in POST data on the TypeError page):

1
2
3
Name: u'Test'
Latitude: u'1234.87654'
Longitude: u'35667.23412'

Giving the Exception Value: unsupported operand type(s) for -: 'str' and 'str'

The traceback is here

Any ideas why this is happening?

asked Feb 28 '11 at 22:42

jcmcmillan's gravatar image

jcmcmillan
32


From the traceback, I see:

1
self.max_digits - self.decimal_places

Which is a mathematical operation (not supported for strings), but you have specified in your definition:

1
2
models.DecimalField(max_digits='16', decimal_places='13')
models.DecimalField(max_digits='16', decimal_places='13')

So, it appears that you're explicitly giving the max_digits and decimal_places attributes string values. I don't think this is related to the input; rather, just that the application is choking when attempting to perform the sanity check on that input (because the sanity check attempts to compute self.max_digits - self.decimal_places).

answered Feb 28 '11 at 23:08

ryans's gravatar image

ryans ♦♦
29361420

edited Feb 28 '11 at 23:09

Oops. Thanks a lot!

(Mar 01 '11 at 11:32) jcmcmillan jcmcmillan's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×653
×34
×1
×1

Asked: Feb 28 '11 at 22:42

Seen: 1,822 times

Last updated: Mar 01 '11 at 11:32

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited