Guest User

Untitled

a guest
Aug 13th, 2019
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def get_context_data(self, **kwargs):
  2. context = super(InvoiceDetail, self).dispatch(*args, **kwargs)
  3. request = self.request
  4.  
  5. if request.GET:
  6. try:
  7. invoice_selector = request.GET.get('invoice_selector', None)
  8. invoice = Invoice.objects.get(id = int(invoice_selector) ) # either a string representing a number or 'add invoice'
  9. context_object_model = invoice
  10. except ValueError:
  11. return HttpResponseRedirect(reverse('accounting:add_invoice'))
  12.  
  13. return context
RAW Paste Data