Opened 8 years ago

Closed 8 years ago

#19236 closed Bug (fixed)

M2M fields should type-check rather than just trying for a split() method

Reported by: Stephen Burrows Owned by: Stephen Burrows
Component: Database layer (models, ORM) Version: 1.5-alpha-1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


Original thread:!topic/django-developers/ZY9uisJynSI

When setting up a relationship between two models, the "relation" argument to add_lazy_relation [1] can be either a Model subclass or a string. But the check for whether it's a string is simply "try calling relation.split(".")". If the argument is a Model subclass with a split() method, this fails horribly and unexpectedly.


Change History (3)

comment:1 Changed 8 years ago by Russell Keith-Magee

Easy pickings: set
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by mrj

Has patch: set

I have opened a pull request for this ticket:

comment:3 Changed 8 years ago by Alex Gaynor <alex.gaynor@…>

Resolution: fixed
Status: newclosed

In 69a0c91c90a3c8f8d5913874aca918aecbe69410:

[1.5.x]Merge pull request #494 from mrj0/model_split

model_split: Fixed #19236 - fixed error for abstract models with a split method

Backport of 8d3f932f18c75fcbb32cf3dd5998445d65b5db0f

Note: See TracTickets for help on using tickets.
Back to Top