Orm Query for this type of situation

8 views
Skip to first unread message

Devender Kumar

unread,
Jun 6, 2019, 7:08:27 AM6/6/19
to Django users
Hi,
I am working on CRM project and stuck with REPORTING part.

I have Accounts , Lead , contact, Calls ,Concern modules
account/Lead can have multiple contacts 
contacts have multiple calls and concerns 
calls have different status like Incoming outgoing missed call etc

Question 
I need to create a reporting system
In this I have to give a functionality like so
list of accounts with counts of :
     contacts, total calls,incoming, outgoing etc

 how can list all this count for a given date ranges calls on all accounts 



Chetan Ganji

unread,
Jun 6, 2019, 7:19:57 AM6/6/19
to django...@googlegroups.com
Right now its an open ended question. 

If you post code for your models here, someone can help you.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1cb5c003-7cbc-4d54-ae5b-21403e543b95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Devender Kumar

unread,
Jun 6, 2019, 10:18:18 AM6/6/19
to django...@googlegroups.com
Account /Lead Model
     account_name
     contact m2m realtion

contact Model
    name 
    phone No

calls Model
    caller no     # person phone no who is calling 
    agent no     #  person who is picking the call (CRM user)
    status <inbound,outbound, missed>
    timestamp
    duration

calls model is populated with some third party software and we are map its caller no and agent no their is no direct relationship

I want to get the list of accounts in particular date range  with:
    total no of contact it have ,
    how many time its contact have called 
    how many calls where missed inbound outbound etc














Devender Kumar

unread,
Jun 7, 2019, 11:06:27 AM6/7/19
to django...@googlegroups.com
Hi,
On this question only I took some step deep and able to find out one part and need your help on the second half.
This requires a good understanding of Django annotation and subquery features 
If you have this thank for reading and helping me in advance 
I am facing problem to filter calls on account.contact list which are realted by contact phone no with and calls phone no
can any one help writing this query





Reply all
Reply to author
Forward
0 new messages