Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Felipe
Does not work, why? remember, we need get each form inline guided on the next line self.initial = [{'attribute': attribute} for attribute in obj.category. attributes.all()] # Important: This start each form with a different value, [{'attribute': 'Colors'}, {'attribute': 'Sizes'}, ..] if you

Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Filipe Ximenes
Think I got it now. Can you see if this stackoverflow answer solves your problem: http://stackoverflow.com/questions/5329586/django-modelchoicefield-filtering-query-set-and-setting-default-value-as-an-obj On Wed, May 27, 2015 at 9:41 AM, Felipe wrote: > Hello, Filipe Ximenes, in fact it is not s

Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Felipe
Hello, Filipe Ximenes, in fact it is not so difficult. To avoid using ajax, what I do is initialize each form inline with a default value. Few ATTRIBUTES has verified and initialize no possibility that the fronentd they can edit. All right up here, but the problem is that for each attribute req

Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Filipe Ximenes
>From what I could understand, you want to change the options of the "value options" field depending on the selected "attribute". Since the choosing of the "attribute" happens in the frontend and there's no page refresh, the backend does not know about it, and therefore cannot filter the "value opt

Re: How to pass a queryset for each different field Admin Inlines

2015-05-26 Thread Felipe
Someone can help me ?, he took days trying to fix this and nothing to get it, if I could just iterate a QuerySet each model choice of the form. The only thing achieved is that a queryset applies to all forms inline, but I need a different one for each inline. def formfield_for_foreignkey(sel

How to pass a queryset for each different field Admin Inlines

2015-05-26 Thread Felipe
Pretend to have in the Django admin, 4 forms inlines, Each with a pair of fields choices, "Attributes" and "Value Option". We have the first pair, which initialize the field one with a value, for example color and other field you must have a queryset the choices.