Guest User

Untitled

a guest
Nov 18th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. class PairRequestForm(forms.Form):
  2. favorite_choices = forms.ChoiceField(choices=[], widget=RadioSelect, required=False)
  3.  
  4. class PairRequestView(FormView):
  5. form_class = PairRequestForm
  6.  
  7. def get_initial(self):
  8. requester_obj = Profile.objects.get(user__username=self.request.user)
  9. accepter_obj = Profile.objects.get(user__username=self.kwargs.get("username"))
  10.  
  11. # `get_favorites()` is the object's method which returns a tuple.
  12. favorites_set = requester_obj.get_favorites()
  13.  
  14. initial = super(PairRequestView, self).get_initial()
  15.  
  16. initial['favorite_choices'] = favorites_set
  17.  
  18. return initial
  19.  
  20. def get_favorites(self):
  21. return (('a', self.fave1), ('b', self.fave2), ('c', self.fave3))
Add Comment
Please, Sign In to add comment