daily pastebin goal
89%
SHARE
TWEET

views.py

a guest Mar 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @method_decorator(login_required, name='dispatch')
  2. class ImmatriculationCreate(CreateView):
  3.     model = Immatriculation
  4.     template_name = 'vol/immatriculation_add.html'
  5.     fields = ['immatriculation',
  6.               'type_avion']
  7.     success_url = '/immatriculation_add/list'
  8.     # template_name_suffix = '_add'
  9.  
  10.     def get_context_data(self, **kwargs):
  11.         context = super(ImmatriculationCreate, self).get_context_data(**kwargs)
  12.         data = Immatriculation.objects.all()
  13.         context['data'] = data
  14.         return context
  15.  
  16.     def form_valid(self, form):
  17.         form.instance.user_id = self.request.user
  18.         return super(ImmatriculationCreate, self).form_valid(form)
  19.  
  20.     def dispatch(self, *args, **kwargs):
  21.         return super().dispatch(*args, **kwargs)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top