简体   繁体   中英

How to write a single query for multiple tables having various columns resulting in the creation of rest api using python-django

I have several tables in my mysql database. I'm supposed to perform a single query for multiple tables having various columns resulting in the creation of rest api using python-django . I have created rest api for a single table but not for more than two tables. How can I solve this issue?

I tried solving using queryset=model.objects.all() but resulted in not knowing which model to use. I also tried raw query but didn't get any result.

Kindly help me out with a solution.

You can use get_model function in Django and you can set which model using.

from django.db.models.loading import get_model
model = get_model('app_name', 'model_name')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM