Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- owl@t14:~$ cd class_site/
- owl@t14:~/class_site$ . venv/bin/activate
- (venv) owl@t14:~/class_site$ python manage.py shell
- Python 3.6.3 (default, Oct 3 2017, 21:45:48)
- Type 'copyright', 'credits' or 'license' for more information
- IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
- In [1]: from django.db.models import Count
- In [2]: from conduit.models import User
- In [3]: from collections import defaultdict
- In [4]: shades = defaultdict(list)
- In [5]: for u in User.objects.all():
- ...: shades[u.color].append(u)
- ...:
- In [6]: shades
- Out[6]:
- defaultdict(list,
- {'#008888': [<User: mazurchikk@gmail.com>,
- <User: grag.oganes@gmail.com>],
- '#0088DD': [<User: artemiy.shvedov20082000@gmail.com>,
- <User: tiger-line-marina@mail.ru>],
- '#00AA88': [<User: malenkaya.bu@gmail.com>,
- <User: elizshuv@gmail.com>],
- '#00AADD': [<User: zavalin.mikhail@gmail.com>,
- <User: aamelnik57@gmail.com>],
- '#00DD88': [<User: nekrashevich.science.2012@gmail.com>,
- <User: serg.salnikov@gmail.com>],
- '#00DDDD': [<User: andreylisitsa1@gmail.com>]})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement