Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion ANN: newforms-admin syntax change for inlines
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
pm13  
View profile  
 More options Sep 9 2007, 5:37 pm
From: pm13 <petr.marh...@gmail.com>
Date: Sun, 09 Sep 2007 14:37:48 -0700
Local: Sun, Sep 9 2007 5:37 pm
Subject: Re: ANN: newforms-admin syntax change for inlines
I have a problem with this changeset. I have some inlines with foreign
keys. By default there is one SQL query for each row - result is not
cached. So I  used this code in formfield_for_dbfield:

if isinstance(db_field, models.ForeignKey):
    kwargs['cache_choices'] = True

The argument cache_choices was used in ModelChoiceField for caching
and I had only one query for one foreign key in inline.

I think that there was call of function "formset_for_model" in each
request (ModelAdmin.get_inline_formsets -> inline_formset ->
formset_for_model). But now this method is called from
ModelAdmin.__init__ (ModelAdmin.__init__ ->  InlineModelAdmin.__init__
-> inline_formset -> formset_for_model).

So if I have two users with different query, I can't cache it. But it
is not possible to have 100 SQL queries (if I have 100 rows). I see
only two solution - use the previous variant (and call
formset_for_model in each request) or somehow intelligently bind form,
its fields and formset (but it seems to be complex). But I don't know
django well - maybe there are other possibilities. What do you think?

I created example of the first solution:
http://code.djangoproject.com/ticket/5372

On 9 Zář, 21:24, "Joseph Kocherhans" <jkocherh...@gmail.com> wrote:

> On 9/8/07, Joseph Kocherhans <jkocherh...@gmail.com> wrote:

> > If you use the newforms-admin branch and the edit inline
> > functionality, you want to read this.

> > I'm planning on breaking the current syntax for defining inlines in
> > the very near future, but I figured I'd warn people and ask for
> > comments first.

> I've checked this in as r6072. No factory functions yet. I'll probably
> hold off on those until the sprint, or start another thread.

> http://code.djangoproject.com/changeset/6072

> Joseph


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.