title: Django - fetch data from database to appear in dropdown list
body: <p>I have a calendar which is suppose to be connected to the current admins-association. When admin picks a date in the calendar by clicking on the mini-calender-plus-icon in the right-top corner:</p>
  
  <p><a href="https://gyazo.com/a74a980a1676a5d961efb3a782f15ddb" rel="nofollow noreferrer">https://gyazo.com/a74a980a1676a5d961efb3a782f15ddb</a></p>
  
  <p>Which will display a form:</p>
  
  <p><a href="https://gyazo.com/e9b7cd46fa84c0017226b5743544f364" rel="nofollow noreferrer">https://gyazo.com/e9b7cd46fa84c0017226b5743544f364</a></p>
  
  <p>As you see, Association-dropdown-list won't show any data from database. I only want it to show association-name of the current admins-association.</p>
  
  <p>Is there something i'm missing?</p>
  
  <p>Looked everywhere for someone with similar issue over long time, with no luck.</p>
  
  <p>Still a newbie so appreciate all your help, folks!</p>
  
  <hr>
  
  <p>models.py</p>
  
  <pre><code>class Administrator(AbstractUser):
          ...
          association = models.ForeignKey(Association)
  
  
  class Event(models.Model):
          ...
          association = models.ForeignKey(Association)
  
  
  class Association(models.Model):
          asoc_name = models.CharField(max_length=50, null=True, blank=True)
  </code></pre>
  
  <hr>
  
  <p>views.py</p>
  
  <pre><code>def event_add_edit(request):
     if request.method == 'POST':
         form = CalForm(request.user, request.POST)
         res = {'success': False}
  
         action = request.POST['action']
         name = request.POST['name']
         location = request.POST['location']
         start = request.POST['start']
         end = request.POST['end']
         allday = request.POST['allday'] == 'true'
         description = request.POST['description']
         synced = request.POST['synced'] == 'true'
         asoc_id = form.request.POST['association']
         association = Association.objects.get(pk=asoc_id.pk)
  
         if action == 'add':
             Event.objects.create(
                name=name,
                location=location,
                start=start,
                end=end,
                allday=allday,
                description=description,
                synced=synced,
                association=asoc
             )
  
             res['success'] = True
             res['message'] = 'added'
             eid = Event.objects.latest('id').id
             res['eid'] = eid
             res['data'] = Event.objects.values().get(id=eid)
         elif action == 'edit':
  
  
             eid = request.POST['eid']
             event = Event.objects.get(id=eid)
             event.name = name
             event.location = location
             event.start = start
             event.end = end
             event.allday = allday
             event.description = description
             event.synced = synced
             event.save()
  
             res['success'] = True
             res['message'] = 'edited'
             res['eid'] = eid
             res['data'] = Event.objects.values().get(id=eid)
  
         return JsonResponse(res)
     else:
         raise Http404
  </code></pre>
  
  <hr>
  
  <p>calendar.js</p>
  
  <pre><code>    $formwrappers: $(".form-wrapper"),
      $formclose: $(".form-close"),
  
     $addEventForm: $("#add-event-form"),
     $addEventAction: $("#add-event-action"),
     $addEventEid: $("#add-event-eid"),
     $addEventSynced: $("#add-event-synced"),
     $addEventTop: $("#add-event-top"),
     $addEventName: $("#add-event-name"),
     $addEventLocation: $("#add-event-location"),
     $addEventSdate: $("#add-event-sdate"),
     $addEventStime: $("#add-event-stime"),
     $addEventEdate: $("#add-event-edate"),
     $addEventEtime: $("#add-event-etime"),
     $addEventAllday: $("#add-event-allday"),
     $addEventDesc: $("#add-event-desc"),
     $addEventAsoc: $("#association"),
  
      showAddForm: function () {
         cal.$addEventAction.val("add");
         cal.$addEventSynced.val("false");
         cal.$addEventName.val("");
         cal.$addEventLocation.val("");
         cal.$addEventAllday[0].checked = false;
         cal.$addEventDesc.val("");
  
         cal.$addEventAsoc.val('association');
  
         var date = new Date($(this).data("date"));
         cal.$addEventTop.text(date.toDateString());
  
         date.setHours(cal.currDate.getHours());
         date.setMinutes(cal.currDate.getMinutes());
  
         cal.$addEventSdate.val(date.toDateInput());
         cal.$addEventStime.val(date.toTimeInput());
         date.shiftHour(1);
         cal.$addEventEdate.val(date.toDateInput());
         cal.$addEventEtime.val(date.toTimeInput());
  
         cal.$addEventForm.addClass("visible");
    }
  </code></pre>
  
  <hr>
  
  <p>calendar.html</p>
  
  <pre><code> &lt;div class="form-wrapper" id="add-event-form"&gt;
      &lt;form action="" method="POST" role="form"&gt;
          {% csrf_token %}
          &lt;input type="hidden" name="action" id="add-event-action" value="add"&gt;
          &lt;input type="hidden" name="eid" id="add-event-eid" value=""&gt;
          &lt;input type="hidden" name="synced" id="add-event-synced" value="false"&gt;
          &lt;ul&gt;
              &lt;li class="form-li"&gt;
                  &lt;span class="form-top" id="add-event-top"&gt;&lt;/span&gt;
                  &lt;span class="btn-fa btn-close form-close"&gt;
                      &lt;i class="fa fa-times"&gt;&lt;/i&gt;
                  &lt;/span&gt;
              &lt;/li&gt;
              &lt;li class="form-li"&gt;
                  &lt;span class="input-field"&gt;
                      &lt;input id="add-event-name" maxlength="50" name="name" placeholder="Event Name" type="text" required&gt;
                  &lt;/span&gt;
              &lt;/li&gt;
              &lt;li class="form-li"&gt;
                  &lt;span class="input-field"&gt;
                      &lt;input id="add-event-location" maxlength="100" name="location" placeholder="Location" required&gt;
                  &lt;/span&gt;
              &lt;/li&gt;
              &lt;li class="form-li"&gt;
                  &lt;span class="input-name"&gt;Starts&lt;/span&gt;
                  &lt;span class="input-field datetime-field"&gt;
                      &lt;input id="add-event-sdate" name="start_date" type="date" &gt;&lt;input id="add-event-stime" name="start_time" type="time" required&gt;
                  &lt;/span&gt;
              &lt;/li&gt;
              &lt;li class="form-li"&gt;
                  &lt;span class="input-name"&gt;Ends&lt;/span&gt;
                  &lt;span class="input-field datetime-field"&gt;
                      &lt;input id="add-event-edate" name="end_date" type="date" &gt;&lt;input id="add-event-etime" name="end_time" type="time" required&gt;
                  &lt;/span&gt;
              &lt;/li&gt;
              &lt;li class="form-li"&gt;
                  &lt;label for="association" class="input-name"&gt; Association&lt;/label&gt;
                  &lt;select id="association"&gt;
                      &lt;option value="{{ association.id }}"&gt;{{ association.asoc_name }} &lt;/option&gt; 
                  &lt;/select&gt;
              &lt;/li&gt;
              &lt;li class="form-li"&gt;
                  &lt;input id="add-event-allday" type="checkbox" name="allday"&gt;
                  &lt;label for="add-event-allday" class="input-name"&gt; All Day&lt;/label&gt;
              &lt;/li&gt;
              &lt;li class="form-li"&gt;
                  &lt;textarea id="add-event-desc" name="description" placeholder="Description" maxlength="200"&gt;&lt;/textarea&gt;
              &lt;/li&gt;
              &lt;li class="form-li"&gt;
                  &lt;input class="form-btn form-close" type="button" value="Cancel"&gt;
                  &lt;input class="form-btn btn-right" type="submit" value="Save"&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <p>forms.py</p>
  
  <pre><code>class CalForm(forms.ModelForm):
      association = forms.ModelChoiceField(queryset=Association.objects.none(),
                                       widget=forms.Select(attrs={'class': 'form-control'}),
                                       required=True)
  
      class Meta:
         model = Event
         exclude = ['last_login', 'date_joined']
         fields = ['association', ]
  
      def __init__(self, user, *args, **kwargs):
         super(CalForm, self).__init__(*args, **kwargs)
         self.fields['association'].queryset = Association.objects.filter(asoc_name=user.association)
  </code></pre>
  
  <hr>
  
  <p>urls.py</p>
  
  <pre><code>urlpatterns = [
     url(r'^calendar/event/get/(?P&lt;start&gt;.+)/(?P&lt;end&gt;.+)/', views.event_get),
     url(r'^calendar/event/delete/', views.event_delete),
     url(r'^calendar/event/addedit/', views.event_add_edit),
     url(r'^calendar/', views.calendar.as_view(), name='calendar'),
  ]
  </code></pre>