How to fill up the field with ForeignKey type (rendered by django Forms)

1,268 views
Skip to first unread message

Domi...@yandex.ru

unread,
May 5, 2012, 2:57:36 AM5/5/12
to Django users
Hi, all.
i am writing here first time, cause sorry if i make a mistake
somwhere.
As well, english not my mother language, so sorry me again. :)

I am starter user of django, and i cant understand how to make one
feature... now try to explain what i need.

I have a model of data named as "Company Info". Structure of a model
dosn't matter right now, and i have another model called "Order List".
Order List have a ForeignKey field for keep relation with Company
Info. This field called "company id".

On my site i made a page for view the Company info, with feature to
add a order right here. It's easy with Django built-in forms, but i
want for data in "company id" field will automatically fill up with
Company ID of that company which i open for details. How can i do it?
By default django render this field as <select> with all instance of
Companys... and i cant find way to solve it.

Thanks for help, hope i didn't take much of yours time.
/Dominis

Dominique Guardiola Falco

unread,
May 5, 2012, 8:05:57 AM5/5/12
to django...@googlegroups.com
Dominis, you need to override the rendering of this field, to mek it a hidden field

look at the answer of this question to have a good code example :

http://stackoverflow.com/questions/621212/another-django-forms-foreign-key-in-hidden-field

Domi...@yandex.ru

unread,
May 5, 2012, 2:45:21 PM5/5/12
to Dominique Guardiola Falco
Thx for answer. I will can try it only at after few days, so cant instantly say solve it my needs or not. I look over link you get me, think it one i needed.

/Dominis


Dominis, you need to override the rendering of this field, to mek it a hidden field

look at the answer of this question to have a good code example :

http://stackoverflow.com/questions/621212/another-django-forms-foreign-key-in-hidden-field
-- 
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/-/GhSdE2N7zY0J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




-- 
С уважением,
Дмитриев Дмитрий.
Reply all
Reply to author
Forward
0 new messages