Skip to content

Conversation

taraskuzyk
Copy link

GeneratedField was added in Django 5.0. I am making this pull request as a draft as I'd like to find out how to contribute to this repository (would love to also document that in a CONTRIBUTING.md).

I based this on JSONField implementation and main changes were taken based on the __init__ in source:

def __init__(self, *, expression, output_field, db_persist=None, **kwargs):
        if kwargs.setdefault("editable", False):
            raise ValueError("GeneratedField cannot be editable.")
        if not kwargs.setdefault("blank", True):
            raise ValueError("GeneratedField must be blank.")
        if kwargs.get("default", NOT_PROVIDED) is not NOT_PROVIDED:
            raise ValueError("GeneratedField cannot have a default.")
        if kwargs.get("db_default", NOT_PROVIDED) is not NOT_PROVIDED:
            raise ValueError("GeneratedField cannot have a database default.")
        if db_persist not in (True, False):
            raise ValueError("GeneratedField.db_persist must be True or False.")

Copy link
Owner

@sbdchd sbdchd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah seems good, if you want to test it, you can add some code inside https://github.com/sbdchd/django-types/blob/main/tests/trout/models.py and the type checker will make sure it works with the types!

@taraskuzyk
Copy link
Author

Will do. Had an unrelated question - I'm using grep for searching across codebase, and the .ignore contains django-stubs. I can only see it being edited once before, is there a reason that file exists?

@sbdchd
Copy link
Owner

sbdchd commented Sep 17, 2025

Oh I think that's a remnant of how the project used to be structured, there was like a dupe folder that was symbolic linked to another folder so you'd get dupes in vscode without the .ignore file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants