OpenUpSA/wazimap

migration fails on FieldTable with `has_total=False`

cliftonmcintosh opened this issue · 1 comments

Is there a trick to migrations for a FieldTable where has_total=False? I've tried to create a FieldTable with that setting, but with no luck.

Here is my table declaration:

FieldTable(['life expectancy'], universe='Population', table_per_level=False,
           has_total=False)

Here is the error I get:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/cmcintosh/.virtualenvs/nepalmap-2.7/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/home/cmcintosh/.virtualenvs/nepalmap-2.7/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 327, in execute
    django.setup()
  File "/home/cmcintosh/.virtualenvs/nepalmap-2.7/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/cmcintosh/.virtualenvs/nepalmap-2.7/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
    app_config.ready()
  File "/home/cmcintosh/.virtualenvs/nepalmap-2.7/local/lib/python2.7/site-packages/wazimap/apps.py", line 12, in ready
    self.load_tables()
  File "/home/cmcintosh/.virtualenvs/nepalmap-2.7/local/lib/python2.7/site-packages/wazimap/apps.py", line 22, in load_tables
    import_module(app.name + '.tables')
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/cmcintosh/code/codefornepal/nepalmap/wazimap_np/tables.py", line 42, in <module>
    has_total=False)
  File "/home/cmcintosh/.virtualenvs/nepalmap-2.7/local/lib/python2.7/site-packages/wazimap/data/tables.py", line 347, in __init__
    super(FieldTable, self).__init__(id=id, model=None, universe=universe, description=description, **kwargs)
  File "/home/cmcintosh/.virtualenvs/nepalmap-2.7/local/lib/python2.7/site-packages/wazimap/data/tables.py", line 111, in __init__
    raise ValueError("I couldn't work out the columns from them model.")
ValueError: I couldn't work out the columns from them model.

Is there another step that needs to be taken?

I see FieldTables with the has_total=False setting in wazimap-za. However, I also can't get python manage.py migration to run for them. Here is the output.

  File "/home/cmcintosh/code/wazimap-za/wazimap_za/tables.py", line 53, in <module>
    FieldTable(['type of crime', 'year'], id='crimes_type_of_crime_year', description='Contact and property crimes by year', year='2015', has_total=False, universe='Crimes', dataset='Police Crime Statistics 2006-2015')
  File "/home/cmcintosh/code/wazimap-za/env/local/lib/python2.7/site-packages/wazimap/data/tables.py", line 347, in __init__
    super(FieldTable, self).__init__(id=id, model=None, universe=universe, description=description, **kwargs)
  File "/home/cmcintosh/code/wazimap-za/env/local/lib/python2.7/site-packages/wazimap/data/tables.py", line 111, in __init__
    raise ValueError("I couldn't work out the columns from them model.")
ValueError: I couldn't work out the columns from them model.

This is a duplicate of #48