Wednesday, August 21, 2013

How can I get value from a FK model?

Hi,

I got this models: http://pastebin.com/w2TmyLzt

First: I used db_columns because I used a legacy database from company ERP.

I try to get, in my template the "descricao" field, in my "mercadoria" model. but I have in my "itenspedido" only "idproduto" not "idmercadoria".

My question is: how can I get "descricao" field from "mercadoria" model in my formset? 

I tried {{ itens.idproduto.idmercadoria.descricao }} , {{ itens.idproduto.idmercadoria.descricao.value }}   and not work.

P.S.: I use modelForm as default form, like this:

class PedidoItensForm(ModelForm):
    class Meta:
        model = ItensPedido

Thanks,

Regards,

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate