title: How to correctly load data from a table to a form?
body: <p>The full branch with the problems is here:</p>
  
  <p><a href="https://github.com/bethlakshmi/GBE2/tree/GBE-459" rel="nofollow">https://github.com/bethlakshmi/GBE2/tree/GBE-459</a></p>
  
  <p>The problem is:</p>
  
  <p>First - I have a form that requires valid items in a given data object:</p>
  
  <pre><code>from [EventScheduleForm][1]:
  
  
  class EventScheduleForm(forms.ModelForm):
      required_css_class = 'required'
      error_css_class = 'error'
  
      day = forms.ChoiceField(choices=conference_days)
      time = forms.ChoiceField(choices=conference_times)
      location = forms.ChoiceField(choices=[
              (loc, loc.__str__()) for loc in
              LocationItem.objects.all().order_by('room__name')])
      duration = DurationFormField(
                 help_text=scheduling_help_texts['duration'])
  ...
  </code></pre>
  
  <p>Next - I have a unit test that seeds some Room objects via a fixture and then tries to commit a submit to the form:</p>
  
  <pre><code>class TestEditEvent(TestCase):
      '''Tests for edit_event view'''
  
      ''' Fixture to create some rooms, location items, and resource items '''
      fixtures = ['scheduler/fixtures/rooms.json']
  
      def setUp(self):
          self.factory = RequestFactory()
          self.s_event = factories.SchedEventFactory.create()
          self.profile_factory = factories.ProfileFactory
          self.client = Client()
          self.room = Room.objects.all().order_by('name').first()
          self.s_event.set_location(self.room)
  
      ...
  
      def test_edit_event_submit_succeed(self):
          '''edit event post succeeds without errors'''
          profile = self.profile_factory.create()
          form_post = self.get_edit_event_form()
          request = self.factory.post('/scheduler/create/GenericEvent/%d' %
                                 self.s_event.pk,
                                 form_post)
          request.user = profile.user_object
          functions.grant_privilege(profile, 'Scheduling Mavens')
          rooms = Room.objects.all().order_by('name')
          for loc in rooms:
              print "Room:" + loc.__str__() + "| \n"
          response = edit_event(request, self.s_event.pk, "GenericEvent")
  
          self.assertEqual(response.status_code, 200)
          print(response.content)
          self.assertFalse('&lt;font color="red"&gt;!&lt;/font&gt;' in response.content)
          self.assertTrue(form_post['title'] in response.content)
          self.assertTrue(form_post['description'] in response.content)
  </code></pre>
  
  <p>What I find is that the line of code:</p>
  
  <pre><code>location = forms.ChoiceField(choices=[
              (loc, loc.__str__()) for loc in
              LocationItem.objects.all().order_by('room__name')])
  </code></pre>
  
  <p>Is failing.  It acts as if there are NO rooms, but the print statements show that the room is properly set and seen in the unit test.</p>
  
  <p>What is wrong with this line?  Is there a better/different way to load the list of room choices that would work differently?</p>
  
  <p>It works in integration - but we've had trouble where we have to restart the database or otherwise tinker with it to get this part of the code to work properly - so something is not right about how it's pulling from the database.</p>
  
  <p>Other notes:
  - Django 1.6 &amp; 1.6.5
  - SQL Lite and MySQL 
  - Linux/Mac
  - Apache and native Django server</p>
  
  <p>have been my baselines</p>