Opened 13 years ago
Closed 13 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 , 13 years ago
| Easy pickings: | set |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 years ago
| Has patch: | set |
|---|
comment:3 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
I have opened a pull request for this ticket:
https://github.com/django/django/pull/494