0

I am getting the following error when executing the command python manage.py loaddata municipios_geo_2013_4674.json.bz2 or python manage.py loaddata municipios_geo_2013_4674.json. How to solve the AttributeError?

Package and json in: https://github.com/znc-sistemas/django-municipios

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/commands/loaddata.py", line 69, in handle
    self.loaddata(fixture_labels)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/commands/loaddata.py", line 109, in loaddata
    self.load_label(fixture_label)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/commands/loaddata.py", line 175, in load_label
    obj.save(using=self.using)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/serializers/base.py", line 205, in save
    models.Model.save_base(self.object, using=using, raw=True, **kwargs)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/base.py", line 837, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/base.py", line 904, in _save_table
    forced_update)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/base.py", line 954, in _do_update
    return filtered._update(values) > 0
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/query.py", line 664, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1191, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 863, in execute_sql
    sql, params = self.as_sql()
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1157, in as_sql
    val = field.get_db_prep_save(val, connection=self.connection)
  File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/contrib/gis/db/models/fields.py", line 182, in get_db_prep_save
    return connection.ops.Adapter(self.get_prep_value(value))
AttributeError: Problem installing fixture '/Users/lidiane/Developer/django/integra-fundaj/municipios_geo_2013_4674.json': 'DatabaseOperations' object has no attribute 'Adapter'
cezar
  • 11,616
  • 6
  • 48
  • 84
LSM
  • 330
  • 2
  • 13
  • Seems these are zipped folder of json, so better you extract and use. – Anup Yadav Jan 15 '18 at 12:47
  • even extracting and changing the command to python manage.py loaddata municipios_geo_2013_4674.json the error is the same. – LSM Jan 15 '18 at 13:05
  • Please show us the settings (from `settings.py`) for **DATABASE->ENGINE**. – cezar Jan 15 '18 at 13:26
  • `DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }` – LSM Jan 15 '18 at 13:37
  • Did you install **[SpatiaLite](https://docs.djangoproject.com/en/2.0/ref/contrib/gis/install/spatialite/)**? – cezar Jan 15 '18 at 14:09
  • I did not know I needed to install. after installing SpatiaLite what's next? – LSM Jan 15 '18 at 14:12
  • Do you intend to use cities geographic data? If so, you'll need to install GeoDjango and its dependencies as well as a database extension that supports geodata, such as SpatialLite (for SQLite) or PostGIS (for PostgreSQL). – Daniel Jan 15 '18 at 14:30
  • The JSON file you want to load contains geodata. For that you need **SpatiaLite** with `sqlite3`. Check the documentation for [GeoDjango](https://docs.djangoproject.com/en/2.0/ref/contrib/gis/). – cezar Jan 15 '18 at 14:52

0 Answers0