Skip to content

contrib.admin.models.LogEntry has malformed ForeignKey declarations #372

@psam44

Description

@psam44

Pylance outputs an error for these:

    user: TypeAlias = models.ForeignKey[User]
    content_type: TypeAlias = models.ForeignKey[ContentType]

It becomes fine with:

    user: models.ForeignKey[User] = ...
    content_type: models.ForeignKey[ContentType] = ...

Bonus: it would be nice to have these additions (like in contrib.auth.models.Permission:

    user_id: int
    content_type_id: int

Note: the other fields (in this and some other contrib.*.models) should probably better be written with this pattern: field: models.FieldType = ..., as in contrib.contenttypes.models and contrib.redirects.models.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions