Skip to content

py-v1.12.0 - django-mptt models are no longer invisible

Choose a tag to compare

@github-actions github-actions released this 09 Aug 17:09
· 40 commits to main since this release

Added

  • django-mptt models are no longer invisible. MPTTModel matched none of
    the base-class patterns the parser recognises, so a class Category(MPTTModel)
    was dropped before a single field was read — absent from the sidebar, the ER
    diagram, and every analyzer. Closing that alone would not have been enough:
    TreeForeignKey, TreeOneToOneField and TreeManyToManyField are checked
    against a literal whitelist too, so the model would have surfaced with its
    scalar fields and no edges at all — worse than hidden, because it looks
    complete. Both halves are fixed. The Tree* fields are thin subclasses of
    Django's own relation fields, so they are reported as the field they
    subclass: TreeForeignKey('self', ...) produces exactly the self-edge a
    plain ForeignKey('self', ...) does, honouring on_delete and
    related_name, and nothing downstream needs to learn about mptt.

    Measured on the vendored corpus: Saleor's product.Category — a real
    MPTTModel with a self-referential parent — now appears in the golden
    snapshot with all of its fields and its children edge. The snapshot diff
    is 76 added lines and no removed ones, so nothing that used to parse was
    disturbed.

    Additive and import-free by design: no django-mptt dependency, so the
    parser keeps working against a project whose venv is broken. Mirrored in
    src/parser.ts so the extension and the CLI cannot disagree about a schema.
    Closes #49.

Fixed

  • DOL021 documented the USE_TZ default wrongly, and overstated what
    timezone.now() returns.
    The page claimed USE_TZ=True was "Django's
    default since 4.0". It was not: the framework default in
    django.conf.global_settings stayed False through 4.2 and became True
    only in 5.0. Since 4.0 the startproject template writes USE_TZ = True
    into generated settings, which is a separate thing — a project upgraded to
    4.x keeps False until someone sets it. Collapsing the two misled exactly
    the most common reader: an existing 4.x project with the setting untouched.
    The page also called timezone.now() "an aware UTC datetime" flatly, when
    it follows the setting and returns naive local time under USE_TZ=False.
    The same claim was duplicated in src/rules/datetime.ts and is corrected
    there too. Found by @Justine0211 while
    translating the page, by declining to translate a statement they could not
    verify against the Django release notes.

Changed

  • The parity_input.py test fixture now carries the from django.db import models import a real models.py would have. No behaviour change — the
    parity test asserts model shape, never line numbers — but the fixture reads
    as genuine Django, and starts clean if that directory is ever linted.
    Contributed by @RinZ27 in
    #64.