Bug fixes for the API generator
diff --git a/planetstack/apigen/api.template.py b/planetstack/apigen/api.template.py
index 0faf947..69e0410 100644
--- a/planetstack/apigen/api.template.py
+++ b/planetstack/apigen/api.template.py
@@ -39,7 +39,7 @@
 	{% if ref.multi %}
 	{{ ref.plural }} = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='{{ ref }}-detail')
 	{% else %}
-	{{ ref }} = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='{{ ref }}-detail')
+	{{ ref }} = serializers.HyperlinkedRelatedField(read_only=True, view_name='{{ ref }}-detail')
 	{% endif %}
 	{% endfor %}
 	class Meta:
diff --git a/planetstack/apigen/modelgen b/planetstack/apigen/modelgen
index e0def4b..db9ae84 100755
--- a/planetstack/apigen/modelgen
+++ b/planetstack/apigen/modelgen
@@ -2,6 +2,7 @@
 
 import os
 import pdb
+import copy
 import sys
 import json
 import re
@@ -69,8 +70,8 @@
 
 	def compute_links(self):
 		for obj in self.values():
-			if (str(obj).lower()=='user'):
-				pdb.set_trace()
+			#if (str(obj).lower()=='user'):
+			#	pdb.set_trace()
 			fields = obj.model._meta.fields
 			for f in fields:
 				if type(f)==ForeignKey and f.name in self.keys():
@@ -86,9 +87,11 @@
 					related_model_name = f.m2m_db_table().rsplit('_',1)[-1]
 
 				if related_model_name in self.keys():
+			#		pdb.set_trace()
 					refobj = self[related_model_name]
-					obj.multi=True
-					refobj.refs.append(obj)
+					cobj = copy.deepcopy(obj)
+					cobj.multi=True
+					refobj.refs.append(cobj)
 
 			
 def main():