diff --git a/representatives/management/commands/export_in_representatives_format.py b/representatives/management/commands/export_in_representatives_format.py index 0a8176531431b5e9abb7329efefef9d6bae843a6..2a3091757c5abb2d10c83ca6df3ec67b470cd4d7 100644 --- a/representatives/management/commands/export_in_representatives_format.py +++ b/representatives/management/commands/export_in_representatives_format.py @@ -8,8 +8,13 @@ class Command(BaseCommand): def handle(self, *args, **options): result = [] + personal_fields = ("first_name", "last_name", "full_name", "birth_place", "cv") + gender_dict = dict(Representative.GENDER) for representative in Representative.objects.all(): reps = {"id": representative.remote_id} + reps["personal"] = {field: getattr(representative, field) for field in personal_fields} + reps["personal"]["gender"] = gender_dict[representative.gender] + reps["personal"]["birth_date"] = representative.birth_date.strftime("%F") if representative.birth_date else None result.append(reps)