You need to set few additional attributes in your foreign key.
First you have to use db_column='', and to_field=''
db_column value would be column name in your table that holds foreign key.
I guess this would be 'name2' in your model that reflects table2
to_field would be reference in field in
Thank you
On Wednesday, November 4, 2015 at 11:19:40 AM UTC-5, frocco 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
If you go with the current solution, you will have to add the to_field
keyword argument to ForeignKey:
clinician = models.ForeignKey(Clinician, to_field='name')
Best,
Gergely
2015-11-05 15:47 GMT+01:00 frocco :
> Thanks, I will look into adding id
>
> If I just do this,
Thanks, I will look into adding id
If I just do this, clinician = models.ForeignKey(Clinician)
I get clinician_id does not exist
In my related table I have
def __unicode__(self):
return self.clinicianname
On Wednesday, November 4, 2015 at 11:19:40 AM UTC-5, frocco wrote:
>
> Hello,
>
> I
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
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
This really depends on the structure of your models. In this case you will
most likely have a ForeignKey in one of your models; if the referenced
model has an __str__() method, the admin site (and also any other forms)
will display names instead of the text "OtherModel object".
On 4 Nov 2015
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 wrote:
> Hello,
>
> I have two existing tables
> table1 has name1
>
> table2 has name2
>
> when I edit table2 in admin, I want a dropdownbox
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
9 matches
Mail list logo