Z
Z
zkweb2015-07-16 11:01:22
Django
zkweb, 2015-07-16 11:01:22

How to get username from database?

Hello! Started learning Django, so I have questions.
1. In the settings.py settings , I specified two databases
2. In the application I created routers.py and indicated which database to work with, but in this application I need to display Username , it turns out from another database - where the auth_user
table is located I did it like this:
from django. contrib.auth.models import User
author = fio_prodavec_id = models.ForeignKey(User,verbose_name = u"Author", null=True, db_column='username')
Everything seems to work, but swears that it cannot find the table (1054, "Unknown column).It turns out from knocking on the second database, in which there is no auth_user. Tell me, please, how can I work with several databases in one model. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Shikanov, 2015-07-16
@zkweb

Django does not currently support using ForeignKeys between different databases.
See off. documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question