What Django shows in that dropdown is the __str__() method of the object, define it to your needs in A :)
On Sun, Nov 26, 2017 at 7:49 PM, Kubilay Yazoğlu <kyazogluu@gmail.com> wrote:
--Hello. I have two models. In one of them, I declared a foreign key to the other one. Since this is done in Django by only specifying the Class name, without specifying the field name(column name), when I try to create an object in admin panel, it pulls the wrong column information.Two models A and B.B has a Foreignkey for accessing A.A has two fields Field1 and Field2.When I try to create an instance of B, in the field of Foreignkey, there is a drop down menu but the content is not from the right field of A.How to specify it?
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 https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ad0d40a3- .cd7f-4f2f-821d-31cc007657b1% 40googlegroups.com
For more options, visit https://groups.google.com/d/optout .
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BFDnhKXdyZRwHrq%2B17zOY7ctWJJDm0S5WzT_%2BXMVyc-a6b%3DFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment