I have described part of this problem in a reply to Keith Bornhorst's thread below "NameError at /trees/add/ - global name 'content_type' is not defined" (
https://groups.google.com/forum/?fromgroups=#!topic/opentreemap-user/JX52c3uO2ws) but now I see further oddities:
Using the web interface, if I try to add a tree in a neighborhood NOT containing any other trees, the add fails with an exception "IntegrityError at /trees/add/ - null value in column "annual_stormwater_management" violates not-null constraint" - but if I first add a tree using uimport.py, the SECOND tree I add in that neighborhood is accepted without a quibble!
The problem traceback through the OTM code goes from treemap/views.py (method tree_add, line 1394) to shortcuts.py (validate_form, 14) to forms.py (save, 157) to models.py (save, 615) and finally to models.py (update_aggregate, 644 in class Plot). Further down the traceback, when execution gets to psycopg2, the SQL is shown as
query
'INSERT INTO "treemap_resourcesummarymodel" ("annual_stormwater_management",
"annual_electricity_conserved", "annual_energy_conserved", "annual_natural_gas_conserved",
"annual_air_quality_improvement", "annual_co2_sequestered", "annual_co2_avoided",
"annual_co2_reduced", "total_co2_stored", "annual_ozone", "annual_nox", "annual_pm10",
"annual_sox", "annual_voc", "annual_bvoc")
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'
where the args for the resources are given as
(None,None,None,None,None,None,None,None,None,None,None,None,None,None,None)
In other words it is trying to initialize everything as null, an invalid value. I notice, for what it's worth, that there are two update_aggregate methods in models.py. In the companion update_aggregate method, in class Tree, there are provisions to initialize to zero, but not in the method in class Plot.
Since I am the only one with this problem, it clearly seems to be an initialization problem on my part. What did I miss in setting up the application to this point? I have updated to the latest 1.3 version with Josh Livni's SanFrancisco templates, lightly modified. I have certainly run syncdb and migrate several times, and when I run python manage.py test treemap I only see a reference to CitizenAtlas in treemap/views.py and some oddities about the csv, kvm, kml, and shp output files, but the test code seems to be able to add a tree (as does the batch load program, uimport.py). What do I have to do to initialize the resources properly for the web interface?
So close and yet so far. I would be *very* grateful for any help (and for any for the "content_type" problem in Keith's thread too!)
Bob