SHARE
TWEET

Untitled

a guest Oct 21st, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def start(request):
  2.  
  3.     SubscriptionFormSet = modelformset_factory(Subscription, can_delete=True, extra=2, exclude=('user'))
  4.    
  5.     if request.method == 'GET':
  6.         formset = SubscriptionFormSet(queryset=Subscription.objects.filter(user=request.user))
  7.         return render_to_response('account.html', {'exsubs': formset}, RequestContext(request))
  8.  
  9.     if request.method == 'POST':
  10.         formset = SubscriptionFormSet(request.POST, request.FILES)
  11.         formset['user': request.user]
  12.         if formset.is_valid():
  13.             formset.save()
  14.         return HttpResponseRedirect("/account/")
RAW Paste Data
Top