Thanks for your help, Daniel. I made the change. On Mon, Sep 21, 2009 at 11:47 PM, Daniel Roseman <dan...@roseman.org.uk>wrote:
> > On Sep 22, 2:31 am, Malcolm MacKinnon <mmack3...@gmail.com> wrote: > > Thanks, Karen. With your help, I manged to fix it. > > Note that - quite apart from your original problem - you've got a > serious inefficiency in this view. You iterate through every customer > to find a matching customer number which, once you get more than a > few, is going to take some time and use up tons of memory. > > Instead of getting all the customers and looping through, just do > this: > > try: > Customer.objects.get(custno=custnum) > except Customer.DoesNotExist: > return HttpResponseRedirect('/denied/') > > -- > DR. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---