It is possible, but in an SQL database it may become ineffective. For this, you will have to make the name field unique, and put an index on it (uniqueness also creates an index, by the way).
For the admin site to display names, though, you still have to define the __str__() method that does only something like "return self.name". However, based on what I said above, if I were you, I would convert the access database so the tables use integer IDs for foreign keys. The admin site will need to fetch data from the other table in both cases, but it can speed up indexing and usage on the long run. 2015-11-05 15:08 GMT+01:00 frocco <faro...@gmail.com>: > The two models from msaccess are linked by name field, not id. > Can I like by name field in django and not use id? > > There was no id in the table > > On Wednesday, November 4, 2015 at 12:35:49 PM UTC-5, Dheerendra Rathor > wrote: >> >> In your model use define __str__ method to name1. Then django admin will >> use name1 in dropdown box. >> >> On Wed, 4 Nov 2015 at 21:50 frocco <far...@gmail.com> wrote: >> >>> Hello, >>> >>> I have two existing tables >>> table1 has name1 >>> >>> table2 has name2 >>> >>> when I edit table2 in admin, I want a dropdownbox that shows values from >>> table1 using name1 >>> both fields are character >>> >>> I cannot change the design, porting from msaccess >>> >>> thanks >>> >>> -- >>> 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...@googlegroups.com. >>> To post to this group, send email to django...@googlegroups.com. >>> Visit this group at http://groups.google.com/group/django-users. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/756fc995-1c2c-4aee-a074-0a327dbc84e0%40googlegroups.com >>> <https://groups.google.com/d/msgid/django-users/756fc995-1c2c-4aee-a074-0a327dbc84e0%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> 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+unsubscr...@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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/b76f6937-5be1-4025-8fe0-093f4542a527%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/b76f6937-5be1-4025-8fe0-093f4542a527%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > 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+unsubscr...@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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACczBUJHosmjBKanE_0x95412YGjOQ9%3DTkD%3DkdTHwXZuhsB%3DtQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.