Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8277437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:41:33+00:00 2026-06-08T08:41:33+00:00

I’m building a database with geo data in it using : PostgreSQL 9.1, Django

  • 0

I’m building a database with geo data in it using : PostgreSQL 9.1, Django 1.3.1, psycopg2 2.4.5 and using libraries GEOS 3.3.0, PostGIS 1.5.4 and ProJ 4.7.0.

I have a command to load the shape files into the database with a bit of optimization to have the shape more simple.

To keep the model simple, i will just put the problematic fields:

class Circonscription(models.Model):
    shape = models.GeometryField()
    simple_shape = models.GeometryField()
    centroid = models.PointField(null=True)

When i want to create one from the shape file, i do this:

Circonscription.objects.create(
            id_cep=feature['id_cep'],
            co_cep=feature['co_cep'],
            nm_cep=feature['nm_cep'],
            nmtri_cep=feature['nmtri_cep'],
            dh_maj=feature['dh_maj'],
            shape=geometry.wkt,
            simple_shape=simple_geometry.wkt,
            centroid=geometry.geos.centroid)

Now when i run my command, it fails with this error:

File "/home/pg/Projets/python/myproject/circonscriptions/management/commands/loadshapefiles.py", line 174, in add_boundaries_for_layer
centroid=geometry.geos.centroid)
File "/home/pg/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/manager.py", line 138, in create
    return self.get_query_set().create(**kwargs)
  File "/home/pg/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/query.py", line 360, in create
    obj.save(force_insert=True, using=self.db)
  File "/home/pg/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/home/pg/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/base.py", line 543, in save_base
    for f in meta.local_fields if not isinstance(f, AutoField)]
  File "/home/pg/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/fields/subclassing.py", line 28, in inner
    return func(*args, **kwargs)
  File "/home/pg/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 786, in get_db_prep_save
    return connection.ops.value_to_db_decimal(self.to_python(value),
  File "/home/pg/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 761, in to_python
    return decimal.Decimal(value)
  File "/usr/lib/python2.7/decimal.py", line 658, in __new__
    raise TypeError("Cannot convert %r to Decimal" % value)
TypeError: Cannot convert <django.contrib.gis.gdal.field.OFTInteger object at 0x2458b50> to Decimal

Does anybody have a clue about it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:41:34+00:00Added an answer on June 8, 2026 at 8:41 am

    It somehow had to do with the encoding of the values and then another error was about this problem which finally solved it.
    Be sure to convert the values to the correct encoding (utf-8) before passing them to the model to save.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
I have some data like this: 1 2 3 4 5 9 2 6
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.