[Fixed]-How to select columns from multiple models in django?

1๐Ÿ‘

โœ…

If you want to select related values you have to specify all parameters you want in values(). Otherwise you will get only the foreignkey to your user model. Try adding the values you want from your user model with __:

query = query.filter(created__range=start_date_range).values('approved', ..., 'user_id__daily_target', 'user_id__username')

Btw if you are creating an API you should have a look at django-rest-framework

๐Ÿ‘คilse2005

0๐Ÿ‘

try this,

Deal.objects.filter(user_id__role_id_id=1, created__range=start_date_range).select_related('user_id').values()

or specify required fields as parameters to values().

๐Ÿ‘คRakesh babu

Leave a comment