Code

#19236 closed Bug (fixed)

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

Reported by: melinath Owned by: melinath
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

Attachments (0)

Change History (3)

comment:1 Changed 18 months ago by russellm

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 18 months ago by mrj

  • Has patch set

I have opened a pull request for this ticket:

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

comment:3 Changed 18 months ago by Alex Gaynor <alex.gaynor@…>

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.