title: Set values for form field by query using filter
body: <p>I want to set the item in dropdown using the query in the form. I want to add employee and the select company which using filter Is_Del= 0. I do not know how to set values for the drop down and where to write this query.</p>
  
  <p>I tried to put in Forms.py, but it is not working.</p>
  
  <p>This is form.py </p>
  
  <pre><code>class EmployeeCreateForm(forms.ModelForm):
       class Meta:
          model = Employee
          fields = ('Emp_Name','Emp_company','Emp_Dept','Emp_Join_Date', 'Emp_End_Date')
  
          def clean(self):
              cleaned_data = super(EmployeeCreateForm, self).clean()
              Emp_Name = cleaned_data.get('Emp_Name')
              Emp_company = cleaned_data.get('Emp_company')
              Emp_Dept = cleaned_data.get('Emp_Dept')
              Emp_Join_Date = cleaned_data.get('Emp_Join_Date')
              Emp_End_Date = cleaned_data.get('Emp_End_Date')
              return cleaned_data
  
       def __init__(self, *args, **kwargs):
          super(EmployeeCreateForm,self).__init__(*args, **kwargs)
          self.fields['Emp_company'].queryset = Company.objects.filter(Is_Del=0)
  </code></pre>
  
  <p>and below is my view.py </p>
  
  <pre><code>class EmployeeCraeteView(LoginRequiredMixin,SuccessMessageMixin,CreateView):
      model=Employee
      form = EmployeeCreateForm
      success_message = " Employee Craeted successfully!"
      success_url="../../company/all-companies"
      template_name = 'employee_form.html'
      fields =[
              'Emp_Name','Emp_company','Emp_Dept','Emp_Join_Date',
              'Emp_End_Date'
              ]
      companies= Company.objects.filter(Is_Del=0)
  
      def form_valid(self,form):
          form.instance.Emp_Crt_By = self.request.user
          if form.cleaned_data['Emp_Join_Date'] &gt;= form.cleaned_data['Emp_End_Date']:
              form.add_error('Emp_End_Date', 'Joining date should be less than Ending date')
              return self.form_invalid(form)
          return super(EmployeeCraeteView, self).form_valid(form)
  </code></pre>
  
  <p>I want to show only this companies in the form which are filtered by Is_Del =0 </p>