5 | | from chat.models import *[[BR]] |
6 | | from django.db import connection[[BR]] |
7 | | c = Campaign.objects.all()[0][[BR]] |
8 | | c.reports.all()[[BR]] |
9 | | [][[BR]] |
10 | | import datetime[[BR]] |
11 | | c.reports.create(type=REPORT_DEFAULT, date=datetime.date.today())[[BR]] |
12 | | <Report: <Default Report 21>>[[BR]] |
13 | | c.reports.all()[[BR]] |
14 | | [<Report: <Default Report 21>>][[BR]] |
15 | | c.reports.get_or_create(type=REPORT_DEFAULT, date=datetime.date.today())[[BR]] |
16 | | (<Report: <Default Report 21>>, False)[[BR]] |
17 | | a = Agent.objects.all()[0][[BR]] |
18 | | c.reports.get_or_create(type=REPORT_AGENT, agent=a, date=datetime.date.today())[[BR]] |
19 | | (<Report: <Agent Report 22>>, True)[[BR]] |
20 | | c.reports.all()[[BR]] |
21 | | [<Report: <Default Report 21>>][[BR]] |
22 | | c.reports.get_or_create(type=REPORT_AGENT, agent=a, date=datetime.date.today())[[BR]] |
23 | | (<Report: <Agent Report 23>>, True)[[BR]] |
24 | | c.reports.all()[[BR]] |
25 | | [<Report: <Default Report 21>>][[BR]] |
26 | | |
27 | | import pprint[[BR]] |
28 | | pprint.pprint(connection.queries)[[BR]] |
| 5 | {{{ |
| 6 | #!python |
| 7 | from chat.models import * |
| 8 | from django.db import connection |
| 9 | c = Campaign.objects.all()[0] |
| 10 | c.reports.all() |
| 11 | [] |
| 12 | import datetime |
| 13 | c.reports.create(type=REPORT_DEFAULT, date=datetime.date.today()) |
| 14 | <Report: <Default Report 21>> |
| 15 | c.reports.all() |
| 16 | [<Report: <Default Report 21>>] |
| 17 | c.reports.get_or_create(type=REPORT_DEFAULT, date=datetime.date.today()) |
| 18 | (<Report: <Default Report 21>>, False) |
| 19 | a = Agent.objects.all()[0] |
| 20 | c.reports.get_or_create(type=REPORT_AGENT, agent=a, date=datetime.date.today()) |
| 21 | (<Report: <Agent Report 22>>, True) |
| 22 | c.reports.all() |
| 23 | [<Report: <Default Report 21>>] |
| 24 | c.reports.get_or_create(type=REPORT_AGENT, agent=a, date=datetime.date.today()) |
| 25 | (<Report: <Agent Report 23>>, True) |
| 26 | c.reports.all() |
| 27 | [<Report: <Default Report 21>>] |
| 28 | |
| 29 | import pprint |
| 30 | pprint.pprint(connection.queries) |