from idea.models import State

def get_first_state():
    """ Get the first state for an idea. """
    return State.objects.get(previous__isnull=True)

@@ -96,16 +96,17 @@
 %22%22%22%0A    
+#
 return S
@@ -145,8 +145,244 @@
 l=True)%0A
+    # previous__isnull breaks functionality if someone creates a new state%0A    # without a previous state set.  since we know the initial state%0A    # is id=1 per fixtures/state.json, use that instead.%0A    return State.objects.get(id=1)%0A

Fix add_idea when multiple States have no previous