#8241: Primary ForeignKeys don't work with FormSets
--------------------------------------+-------------------------------------
          Reporter:  sciyoshi         |         Owner:  nobody
            Status:  new              |     Milestone:  1.0   
         Component:  Admin interface  |       Version:  SVN   
        Resolution:                   |      Keywords:        
             Stage:  Accepted         |     Has_patch:  1     
        Needs_docs:  0                |   Needs_tests:  1     
Needs_better_patch:  0                |  
--------------------------------------+-------------------------------------
Changes (by semenov):

  * needs_better_patch:  1 => 0

Comment:

 sciyoshi, first of all, thanks for your patch. It inspired me for further
 analysis of the problem. :)

 From what I've discovered, your patch suffers from the following:

 1. It curcumvents into the naming convention of form fields and adds a
 form field named user_id (i.e., taken as field.attname, not as
 field.name). At first glance, that seems to be ok: the field is filled by
 model_to_dict(), passed thru browser POST, but then ignored by
 save_instance(). Alas, that would break things if a model had TWO fields
 like user=OneToOneField() and user_id=CharField(). We shouldn't be messing
 with the naming convention: all form fields should always use field.name
 as their names.

 2. The patch breaks BaseModelFormSet.add_fields() contract, which
 currently adds a new field if (and only if) a primary key is an AutoField
 -- what I consider to be a desired behaviour.

 I'm attaching the updated patch (vs [8461]), which resolves the both
 problems.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8241#comment:7>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to