{"id":15295728,"url":"https://github.com/2degrees/djeneralize","last_synced_at":"2025-10-07T08:30:32.434Z","repository":{"id":1328788,"uuid":"1274430","full_name":"2degrees/djeneralize","owner":"2degrees","description":"Generalization of specialized models for Django","archived":true,"fork":false,"pushed_at":"2020-02-11T21:46:54.000Z","size":124,"stargazers_count":43,"open_issues_count":11,"forks_count":6,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-10-02T15:26:27.721Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://packages.python.org/djeneralize/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2degrees.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-01-20T11:59:37.000Z","updated_at":"2023-11-03T16:04:45.000Z","dependencies_parsed_at":"2022-08-16T13:10:12.382Z","dependency_job_id":null,"html_url":"https://github.com/2degrees/djeneralize","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/2degrees/djeneralize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2degrees%2Fdjeneralize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2degrees%2Fdjeneralize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2degrees%2Fdjeneralize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2degrees%2Fdjeneralize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2degrees","download_url":"https://codeload.github.com/2degrees/djeneralize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2degrees%2Fdjeneralize/sbom","scorecard":{"id":2916,"data":{"date":"2025-08-11","repo":{"name":"github.com/2degrees/djeneralize","commit":"ef456292397888bd0476786d9f4ab2854b3604ef"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENCE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENCE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"14 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-6 / GHSA-2f9x-5v75-3qv4","Warn: Project is vulnerable to: PYSEC-2017-9 / GHSA-37hp-765x-j95x","Warn: Project is vulnerable to: PYSEC-2016-18 / GHSA-3f2c-jm6v-cr35","Warn: Project is vulnerable to: PYSEC-2021-98 / GHSA-68w8-qjq3-2gfm","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: GHSA-8x94-hmjh-97hq","Warn: Project is vulnerable to: PYSEC-2016-2 / GHSA-c8c8-9472-w52h","Warn: Project is vulnerable to: PYSEC-2016-3 / GHSA-crhm-qpjc-cm64","Warn: Project is vulnerable to: PYSEC-2017-10 / GHSA-h4hv-m4h4-mhwg","Warn: Project is vulnerable to: GHSA-hmr4-m2h5-33qx","Warn: Project is vulnerable to: PYSEC-2016-17 / GHSA-mv8g-fhh6-6267","Warn: Project is vulnerable to: PYSEC-2018-5 / GHSA-r28v-mw67-m5p9","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: PYSEC-2019-16 / GHSA-vfq6-hq5r-27r6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-14T12:57:01.166Z","repository_id":1328788,"created_at":"2025-08-14T12:57:01.166Z","updated_at":"2025-08-14T12:57:01.166Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278742889,"owners_count":26037915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-30T18:07:44.292Z","updated_at":"2025-10-07T08:30:31.995Z","avatar_url":"https://github.com/2degrees.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# djeneralize\n\nGeneralizations of specialized models for Django.\n\n**djeneralize is not longer under development!**\n\n## Migrating from djeneralize\n\nWe have had success migrating djeneralize models to \n[django-polymorphic](https://pypi.python.org/pypi/django_polymorphic). The \nfollowing procedure has worked for us:\n\n1. replace `BaseGeneralizationModel` with `PolymorphicModel`\n2. remove all `Meta.specialization_type` attributes\n3. replace all `Model.specializations` calls with `Model.objects` calls\n4. remove all `as_specialization()` calls\n5. run `makemigrations` \n6. manually add migration calling `reset_polymorphic_ctypes` on all Polymorphic \nmodels\n7. run `migrate`\n\n\n### Example Model Changes and Migrations\n\nFor the following djeneralize example model:\n\n```python\nfrom django.db.models.fields import CharField, DateTimeField, ForeignKey, \\ \n    TextField, DecimalField\n \nfrom djeneralize.models import BaseGeneralizationModel\n \n \nclass Question(BaseGeneralizationModel):\n    wording = CharField(max_length=256)\n    \n    \nclass TextQuestion(Question):\n    class Meta:\n        specialization = 'text'\n        \n        \nclass NumericQuestion(Question):\n    unit = CharField(max_length=2)\n    \n    class Meta:\n        specialization = 'numeric'\n        \n        \nclass Answer(BaseGeneralizationModel):\n    timestamp = DateTimeField(null=True)    \n    \n    \nclass TextAnswer(Answer):\n    question = ForeignKey(TextQuestion, related_name='answers')\n \n    value = TextField()\n    \n    class Meta:\n        specialization = 'text'\n \n \nclass NumericAnswer(Answer):\n    question = ForeignKey(NumericQuestion, related_name='answers')\n \n    value = DecimalField()\n \n    class Meta:\n        specialization = 'numeric'\n```\n\nmodify it to become:\n\n```python\nfrom django.db.models.fields import CharField, DateTimeField, ForeignKey, \\ \n    TextField, DecimalField\n \nfrom polymorphic.models import PolymorphicModel\n \n \nclass Question(PolymorphicModel):\n \n    wording = CharField(max_length=256)\n    \n    \nclass TextQuestion(Question):\n    pass\n        \n        \nclass NumericQuestion(Question):\n    unit = CharField(max_length=2)\n        \n        \nclass Answer(PolymorphicModel):\n    timestamp = DateTimeField(null=True)    \n \n \nclass TextAnswer(Answer):\n    question = ForeignKey(TextQuestion, related_name='answers')\n \n    value = TextField()\n \n \nclass NumericAnswer(Answer):\n    question = ForeignKey(NumericQuestion, related_name='answers')\n \n    value = DecimalField()\n```\n\nNow run `manage.py makemigrations`; imagining that this creates the file `myapp/migrations/0002_auto_20170928_1100.py` \nyou must now make the following file (`myapp/migrations/0003_this_name_does_not_matter.py`):\n\n```python\nfrom __future__ import unicode_literals\n \nfrom django.db import migrations\nfrom polymorphic.utils import reset_polymorphic_ctype\n \n \ndef _update_content_types(apps, schema_editor):\n    answer_model = apps.get_model('myapp', 'Answer')\n    numeric_answer_model = apps.get_model('myapp', 'NumericAnswer')\n    text_answer_model = apps.get_model('myapp', 'TextAnswer')\n    \n    question_model = apps.get_model('myapp', 'Question')\n    numeric_question_model = apps.get_model('myapp', 'NumericQuestion')\n    text_question_model = apps.get_model('myapp', 'TextQuestion')\n    \n    reset_polymorphic_ctype(\n        answer_model,\n        text_answer_model,\n        numeric_answer_model,\n    )\n     \n    reset_polymorphic_ctype(\n        question_model,\n        text_question_model,\n        numeric_question_model,\n    )\n \nclass Migration(migrations.Migration):\n    dependencies = [\n        ('myapp', '0002_auto_20170928_1100'),\n    ]\n \n    operations = [\n        migrations.RunPython(_update_content_types, migrations.RunPython.noop)\n    ]\n\n```\n\nNow run `manage.py migrate` and your models should be consistent.\n\nYou will have to look through your code to find uses of `djeneralize` specifics, \nbut we have had no issues in swapping these for `Polymorphic` patterns.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2degrees%2Fdjeneralize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2degrees%2Fdjeneralize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2degrees%2Fdjeneralize/lists"}