Wednesday, April 29, 2020

Re: How to use ModelChoiceField? I whould like to filter the output from a field form.




class OrderNewBigPrintView(LoginRequiredMixin, CustomSuccessMessageMixin, CreateView):
    model 
= Order
    template_name 
= 'new_order_bp.html'
    form_class 
= OrderForm
    success_url 
= reverse_lazy('orders')
    success_msg 
= 'Ok'

              # get_initial позволяет установить значения полей связанной формы
              def get_initial(self):        
                  self.initial["name_job"] = TypJob.objects.filter(author__id=self.request.user.id)
         # вернуть нужно копию объекта    
                  return self.initial.copy() 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4e0dd931-7c34-4be8-9a1c-3a42e611894e%40googlegroups.com.

No comments:

Post a Comment