Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
1,440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. owl@t14:~$ cd class_site/
  2. owl@t14:~/class_site$ . venv/bin/activate
  3. (venv) owl@t14:~/class_site$ python manage.py shell
  4. Python 3.6.3 (default, Oct  3 2017, 21:45:48)
  5. Type 'copyright', 'credits' or 'license' for more information
  6. IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
  7.  
  8. In [1]: from django.db.models import Count
  9.  
  10. In [2]: from conduit.models import User
  11.  
  12. In [3]: from collections import defaultdict
  13.  
  14. In [4]: shades = defaultdict(list)
  15.  
  16. In [5]: for u in User.objects.all():
  17.    ...:     shades[u.color].append(u)
  18.    ...:    
  19.  
  20. In [6]: shades
  21. Out[6]:
  22. defaultdict(list,
  23.             {'#008888': [<User: mazurchikk@gmail.com>,
  24.               <User: grag.oganes@gmail.com>],
  25.              '#0088DD': [<User: artemiy.shvedov20082000@gmail.com>,
  26.               <User: tiger-line-marina@mail.ru>],
  27.              '#00AA88': [<User: malenkaya.bu@gmail.com>,
  28.               <User: elizshuv@gmail.com>],
  29.              '#00AADD': [<User: zavalin.mikhail@gmail.com>,
  30.               <User: aamelnik57@gmail.com>],
  31.              '#00DD88': [<User: nekrashevich.science.2012@gmail.com>,
  32.               <User: serg.salnikov@gmail.com>],
  33.              '#00DDDD': [<User: andreylisitsa1@gmail.com>]})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement