Here again...

  Im trying to understand if there is a real need to brake symmetry in a
  ManyToMany relation, and how can that be bypassed creating a model.

  Let's use User/Group models. 

  class User(model.Model):
      ...
      groups = models.ManyToManyField(Group,...)

  creating a form using form_for_models I get a nice widget(*) created to
  select groups to which the user belongs. 

  The reverse is not true, you don't get a widget for the user in the form
  created for Group.

  Why that?

  The tecnical reason is that form_for_model has a loop as this:

      for f in model._meta.fields + model._meta.many_to_many:
         ...

  and mode._meta.many_to_may is not symmetrycally filled, of course I could
  get the list using model._meta.get_all_related_many_to_many_objects() but
  
  I think I miss the reason of the difference between many_to_many
  attribute and method output, so that I don't know if the way to go should be
  to fix the attribute to have complete information (as I would think) or to
  change form_for_model to use the get_all... method.

  [Anoter solution is to write the definition in both models, using db_table,
  but that will make syncdb complain the table already exits, when tries to
  create the middle table for the second time...]

  
   sandro
   *:-)


(*) not really, that was true with oldforms, now you must define a
    formfield_callback... 


-- 
Sandro Dentella  *:-)
http://www.tksql.org                    TkSQL Home page - My GPL work

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to