Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pees = PostExtraElection.objects.filter(election__slug__in=['local.aberdeen-city.2017-05-04', 'local.aberdeenshire.2017-05-04', 'local.orkney-islands.2017-05-04', 'local.argyll-and-bute.2017-05-04', 'local.angus.2017-05-04', 'local.eilean-siar.2017-05-04', 'local.city-of-edinburgh.2017-05-04', 'local.clackmannanshire.2017-05-04', 'local.dundee-city.2017-05-04', 'local.east-renfrewshire.2017-05-04', 'local.east-lothian.2017-05-04', 'local.glasgow-city.2017-05-04', 'local.dumfries-and-galloway.2017-05-04', 'local.inverclyde.2017-05-04', 'local.east-ayrshire.2017-05-04', 'local.east-dunbartonshire.2017-05-04', 'local.south-ayrshire.2017-05-04', 'local.falkirk.2017-05-04', 'local.fife.2017-05-04', 'local.midlothian.2017-05-04', 'local.the-scottish-borders.2017-05-04', 'local.south-lanarkshire.2017-05-04', 'local.stirling.2017-05-04', 'local.highland.2017-05-04', 'local.moray.2017-05-04', 'local.west-dunbartonshire.2017-05-04', 'local.west-lothian.2017-05-04', 'local.north-ayrshire.2017-05-04', 'local.north-lanarkshire.2017-05-04', 'local.perth-and-kinross.2017-05-04', 'local.renfrewshire.2017-05-04', 'local.shetland-islands.2017-05-04'])
- pes = PostExtra.objects.filter(elections__in=[p.election for p in pees])
- [(p.slug, p.elections.count()) for p in pes if p.elections.count() > 1]
- # [(u'UTW:S13002650', 2)]
- p = PostExtra.objects.get(slug="UTW:S13002650")
- [e.slug for e in p.elections.all()]
- # [u'local.glasgow-city.2017-05-04', u'local.glasgow.anderston-city.2016-05-05']
- lines = []
- for pe in pes:
- election = pe.elections.get(election_date="2017-05-04").slug
- for membership in pe.base.memberships.all():
- lines.append([election, pe.base.label, membership.person.name, membership.person.extra.get_absolute_url()])
- import csv
- import sys
- out = csv.writer(sys.stdout)
- for line in lines:
- out.writerow(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement