WebFaction
Community site: login 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:

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

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 28 Feb '11, 22:42

jcmcmillan
312
accept rate: 0%


From the traceback, I see:

self.max_digits - self.decimal_places

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

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

permanent link

answered 28 Feb '11, 23:08

ryans ♦♦
5.0k93260
accept rate: 43%

edited 28 Feb '11, 23:09

Oops. Thanks a lot!

(01 Mar '11, 11:32) jcmcmillan
Your answer
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

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×908
×40
×1
×1

question asked: 28 Feb '11, 22:42

question was seen: 6,606 times

last updated: 01 Mar '11, 11:32

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM