Ok, looks like just adding a *ModelForm* and getting that field does the work. Sorry for the noobish time.
El martes, 20 de septiembre de 2016, 8:23:19 (UTC+2), RompePC escribió: > > Talking in the way of getting the HTML widget yeah, maybe. But what I > wanna do is, given a model *A* with a FK *a_fk*, I want *a_fk* to be > available in views other than add. So I wanna get *a_fk* and pass it to > another context (*changelist_view* specifically). But the nearest thing I > get is *self.model.a_fk* > > El lunes, 19 de septiembre de 2016, 19:47:13 (UTC+2), Tim Graham escribió: >> >> So basically ModelAdmin.list_editable but without the icons on the side? >> >> If you never want the inline editing buttons for all models, you could >> override the admin/related_widget_wrapper.html template and remove the >> buttons. >> >> https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/related_widget_wrapper.html >> >> Otherwise, I'm out of (simple) ideas. >> >> On Monday, September 19, 2016 at 12:58:44 PM UTC-4, RompePC wrote: >>> >>> Yeah, I'm so sorry, it's hard to understand. I'll post an image of the >>> Django tutorial of what I mean: >>> >>> >>> <https://lh3.googleusercontent.com/-FTHbS2UIF10/V-AY2P4_iqI/AAAAAAAAAj0/EStJWTU7xJwOwDI8OODZ_L0S0JyNHJ7pgCLcB/s1600/admin10.png> >>> I want that the FK widget (the one for *Question*) could be available >>> in other panel admin's views (as listing) (with no CRUD icons along). The >>> problem is to get the field correctly, as I just only get str >>> representations of the field or the widget. >>> >>> El lunes, 19 de septiembre de 2016, 18:53:56 (UTC+2), Tim Graham >>> escribió: >>>> >>>> I still don't understand the goal. Maybe you can mock up a screenshot >>>> and/or give a code example. >>>> >>>> On Monday, September 19, 2016 at 12:41:32 PM UTC-4, RompePC wrote: >>>>> >>>>> Nope, as I wanna the ModelChoiceField rendered in the filter list I >>>>> did in my own (not the sided one). >>>>> >>>>> El lunes, 19 de septiembre de 2016, 18:15:17 (UTC+2), Tim Graham >>>>> escribió: >>>>>> >>>>>> ModelAdmin.list_editable? >>>>>> >>>>>> >>>>>> https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable >>>>>> >>>>>> On Monday, September 19, 2016 at 11:05:22 AM UTC-4, RompePC wrote: >>>>>>> >>>>>>> Nope, it isn't a lookup separator: for simply understanding, I wanna >>>>>>> get the FK widget (the HTML, the select, all of that) that is show when >>>>>>> adding an object that has a related key (say, adding a new City and >>>>>>> selecting its Country in the same model, 'cause a City belongs to a >>>>>>> Country) so I can use it anywhere in my panel. >>>>>>> >>>>>>> El lunes, 19 de septiembre de 2016, 16:31:55 (UTC+2), Tim Graham >>>>>>> escribió: >>>>>>>> >>>>>>>> Is your request https://code.djangoproject.com/ticket/10743? >>>>>>>> >>>>>>>> On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote: >>>>>>>>> >>>>>>>>> Yep, the second one is what I wanna do. Althrough they aren't >>>>>>>>> inlines, but like FK filter choices in the list view (not the default >>>>>>>>> ones). >>>>>>>>> It's hard to understand, I know it can be done, but don't know >>>>>>>>> how. Will keep searching and throw some light here when done. >>>>>>>>> >>>>>>>>> El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic >>>>>>>>> coues escribió: >>>>>>>>>> >>>>>>>>>> I looked into it after my first reply and my suggestion was >>>>>>>>>> wrong. >>>>>>>>>> >>>>>>>>>> If you want to display the value of a foreign key object's >>>>>>>>>> property in >>>>>>>>>> the admin page to select an object to change, you can add a >>>>>>>>>> callable >>>>>>>>>> to list_display. >>>>>>>>>> For exemple, ` list_display = ('title', lambda o: >>>>>>>>>> getattr(o.author, >>>>>>>>>> "name", "-"),) `. The callable will get one argument, an instance >>>>>>>>>> of >>>>>>>>>> the model. >>>>>>>>>> >>>>>>>>>> If you want to display a field to change a property of a foreign >>>>>>>>>> key >>>>>>>>>> object, I haven't found a way. Best option might be a inline >>>>>>>>>> model >>>>>>>>>> admin. >>>>>>>>>> >>>>>>>>>> 2016-09-19 12:24 GMT+02:00 RompePC <[email protected]>: >>>>>>>>>> > Hi again, I didn't have time to try it until now, but I just >>>>>>>>>> realized that >>>>>>>>>> > maybe I asked the wrong way. What I wanna do is to render the >>>>>>>>>> widget >>>>>>>>>> > associated to that FK in the panel, not its name. So I need to >>>>>>>>>> pass the >>>>>>>>>> > field or its rendered content to the context, but I don't know >>>>>>>>>> how to do get >>>>>>>>>> > it. >>>>>>>>>> > >>>>>>>>>> > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic >>>>>>>>>> coues >>>>>>>>>> > escribió: >>>>>>>>>> >> >>>>>>>>>> >> Have you tried something like author__name ? Assuming a model >>>>>>>>>> with an >>>>>>>>>> >> author foreign key. >>>>>>>>>> >> >>>>>>>>>> >> 2016-09-16 8:56 GMT+02:00 RompePC <[email protected]>: >>>>>>>>>> >> > I would like to pass to the list display view a FK field of >>>>>>>>>> the admin >>>>>>>>>> >> > form >>>>>>>>>> >> > (like the ones when adding a new row). But I don't see the >>>>>>>>>> way of doing >>>>>>>>>> >> > it, >>>>>>>>>> >> > although I've searched along many properties of the model >>>>>>>>>> admin to get >>>>>>>>>> >> > it. >>>>>>>>>> >> > >>>>>>>>>> >> > Anyone did something like that before? >>>>>>>>>> >> > >>>>>>>>>> >> > -- >>>>>>>>>> >> > You received this message because you are subscribed to the >>>>>>>>>> Google >>>>>>>>>> >> > Groups >>>>>>>>>> >> > "Django users" group. >>>>>>>>>> >> > To unsubscribe from this group and stop receiving emails >>>>>>>>>> from it, send >>>>>>>>>> >> > an >>>>>>>>>> >> > email to [email protected]. >>>>>>>>>> >> > To post to this group, send email to >>>>>>>>>> [email protected]. >>>>>>>>>> >> > Visit this group at >>>>>>>>>> https://groups.google.com/group/django-users. >>>>>>>>>> >> > To view this discussion on the web visit >>>>>>>>>> >> > >>>>>>>>>> >> > >>>>>>>>>> https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >> > For more options, visit https://groups.google.com/d/optout. >>>>>>>>>> >> >>>>>>>>>> >> >>>>>>>>>> >> >>>>>>>>>> >> -- >>>>>>>>>> >> >>>>>>>>>> >> Cordialement, Coues Ludovic >>>>>>>>>> >> +336 148 743 42 >>>>>>>>>> > >>>>>>>>>> > -- >>>>>>>>>> > You received this message because you are subscribed to the >>>>>>>>>> Google Groups >>>>>>>>>> > "Django users" group. >>>>>>>>>> > To unsubscribe from this group and stop receiving emails from >>>>>>>>>> it, send an >>>>>>>>>> > email to [email protected]. >>>>>>>>>> > To post to this group, send email to [email protected]. >>>>>>>>>> >>>>>>>>>> > Visit this group at >>>>>>>>>> https://groups.google.com/group/django-users. >>>>>>>>>> > To view this discussion on the web visit >>>>>>>>>> > >>>>>>>>>> https://groups.google.com/d/msgid/django-users/a99dac72-a527-4968-92f5-0a4c405c1778%40googlegroups.com. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> > >>>>>>>>>> > For more options, visit https://groups.google.com/d/optout. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> >>>>>>>>>> Cordialement, Coues Ludovic >>>>>>>>>> +336 148 743 42 >>>>>>>>>> >>>>>>>>> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fbe6c40e-daec-4ec5-9594-59ab99aea3d8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

