def ensure_http_prefix_contact(apps, schema_editor):
        Contact = apps.get_model("membership", "Contact")
        # Contacts with broken homepage field value
        for contact in Contact.objects\
                .exclude(homepage='')\
                .exclude(homepage__startswith="http://")\
                .exclude(homepage__startswith="https://"):
            if contact.homepage:
                if ":/" not in contact.homepage:
                    contact.homepage = "http://{uri}".format(uri=contact.homepage)
                    contact.save()
dataset/ETHPy150Open kapsiry/sikteeri/membership/migrations/0003_ensure_http_prefix_contact_uris.py/Migration.ensure_http_prefix_contact/original