SHARE
TWEET

Untitled

a guest Jun 20th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class CreateVote(CreateView):
  2.      model = Vote
  3.      template_name = 'art_detail.html'
  4.      fields = ()
  5.  
  6. def get_initial(self):
  7.     initial = super().get_initial()
  8.     initial['art_id'] = self.kwargs['slug']
  9.     initial['author_id'] = self.request.user
  10.     return initial
  11.  
  12. def form_valid(self, form):
  13.     model = form.save(commit=False)
  14.     model.save()
  15.     return HttpResponseRedirect(self.get_success_url())
  16.  
  17. def get_success_url(self):
  18.     return reverse('art_detail')
  19.  
  20.  
  21. Traceback:
  22.         return self.form_valid(form) ...
  23.  ▼ Local vars
  24.  Variable   Value
  25.  args   ()
  26.  form   < VoteForm bound=True, valid=True, fields=()>
  27.  kwargs {'slug': 'rrcom'}
  28.  request    <WSGIRequest: POST '/poll/arts/rrcom/vote/'>
  29.  self   <coll.views.CreateVote object at 0x0000000004709E48>
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