On Mar 29, 8:31 pm, "Gary Wilson" <[EMAIL PROTECTED]> wrote:
> On Mar 29, 2:26 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
>
> > But in the dev environment I can see pretty well that the view is
> > functioning very quickly.  So your hunch about the problem lying in
> > the templates is probably right.
>
> If you aren't seeing the slowdown on your dev server, then you
> shouldn't be seeing a slowdown on your production server either.  Is
> your dev database loaded with the same amount of data as production?

Yes

> When you say that the view is functioning very quickly, do you mean
> the time from request to page render?  If so, the template is already
> getting run and is probably not your problem.

My conclusion that the view was functioning quickly was from a print
time.time() test I did.  According to that it took .2 secs from start
to the point right before the view called render_to_response().
Again, this was on my dev site which doesn't have as much data.

>
> > Let me know what you think.
>
> In your view, I think you can take this code:
>
> f = newforms.form_for_model(PresentationEval)
> f.base_fields['presentation'].widget = widgets.HiddenInput()
> f.base_fields['application'].widget = widgets.HiddenInput()
> f.base_fields['topic_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
> f.base_fields['substance_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
> f.base_fields['expertise_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
> f.base_fields['relevance_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
> f.base_fields['overall_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
>
> out of the loop, as it is just constructing the form class that will
> be used to instantiate your pForms instances.

I took that out of the loop and it made a big difference.  Makes total
sense too, I was doing a lot of extra work there but didn't realize
it.  The time difference was dramatic.  I timed it using basic
sys.stderr.write() and .flush() with apache2/mod_python.

creating classes inside the loop, calling newforms.form_for_model() 19
times:
for p in ... 1175239555.13
done with for p in ... 1175239601.91
47 Seconds?!

only creating the class once:
for p in ... 1175239882.93
done with for p in ... 1175239886.7
3 Seconds!

So I think that was it.

This is on django-svn 4455, a bit outdated. I tried updating a few
days ago but some non-backwards compat code bit me and had to back off
for a bit.

Thanks Gary and Everyone!


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to