I am executing the following raw query and getting error: Raw query must include the primary key
.
user = User.objects.get(email_id=request.session['email_id'])
query = 'select date, sum(revenue) from dashboard_revenue where app_id_id IN (select id from dashboard_app where user_id_id=1) group by date'
details = Revenue.objects.raw(query)
context = {'details': details}
return render(request, 'index.html', context)
Can someone correct this query or help me with the corresponding query for django?