Opened 12 years ago

Closed 12 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

Description

Original thread: https://groups.google.com/forum/?fromgroups=#!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.

[1] https://github.com/django/django/blob/master/django/db/models/fields/related.py#L25

Change History (3)

comment:1 by Russell Keith-Magee, 12 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

comment:2 by mrj, 12 years ago

Has patch: set

I have opened a pull request for this ticket:

https://github.com/django/django/pull/494

comment:3 by Alex Gaynor <alex.gaynor@…>, 12 years ago

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