Wednesday, August 1, 2012

Re: combobox prepopulated to only related objects to "self"

interesting!!! i will give it a try, and let you know.

thanks

2012/8/1 Anton Baklanov <antonbaklanov@gmail.com>
you can try something like that:

    group = ...
    choices = [(product.pk, product.name) for product in group.product_set.all()]
    form.fields["myfield"].choices = choices


On Wed, Aug 1, 2012 at 1:17 AM, Ignacio Soto <isoto@ingehost.cl> wrote:
Hi everyone

i have this model

GROUP and Product


product has a group field thath is foreignkey to GROUP.


and Group has foreignKey to Product to select primary product.

so i want to have a group with many products and one is the "primary product".


so...i could do this by select inline products with "trough" and search an intermediary Model (boolean field).

but it let me select  more than one promary,


the solution is the model this way:.

product has a group field thath is foreignkey to GROUP.


and Group has foreignKey to Product to select primary product.

so i want to have a group with many products and one is the "primary product".

but the primaryproduct field in group will be prepopulated with only the related products to this group.


how i prepopulate the select(combobox) with the reverse query ?






--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/d3UpfhONEWwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
Regards,
Anton Baklanov

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
__

Ignacio Soto Reveco
Staff IngeHost

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment