Created attachment 8650763 [details] Screenshot from 2015-08-20 16:24:48.png I was trying to hide the GTest job I added in bug 1196464 and got the attached error. Not sure what's going on here, but the job is visible on try (and red) for now.
This seems to be a Django 1.8 update regression: https://docs.djangoproject.com/en/1.8/releases/1.8/#select-related-now-checks-given-fields select_related() now validates that the given fields actually exist. Previously, nonexistent fields were silently ignored. Now, an error is raised: ... The validation also makes sure that the given field is relational: >>> book = Book.objects.select_related('name') Traceback (most recent call last): ... FieldError: Non-relational field given in select_related: 'name'
Priority: -- → P1
Summary: Error attempting to add to exclusion profile → Error adding exclusion profile after update to Django 1.8 ("Non-relational field given in select_related: 'info'")
The line in question is here: https://github.com/mozilla/treeherder/blob/bae6e0492ac41f09279b13f7f23782f0f00ee370/treeherder/model/models.py#L451 So select_related() is documented here: https://docs.djangoproject.com/en/1.8/ref/models/querysets/#select-related However one thing it doesn't make that clear, but that is mentioned here: http://timmyomahony.com/blog/misconceptions-select_related-in-django/ ...is that it cannot be used for ManyToMany, but yet that's what we're doing here: https://github.com/mozilla/treeherder/blob/bae6e0492ac41f09279b13f7f23782f0f00ee370/treeherder/model/models.py#L419
(Meant to say: that same blog article suggests using prefetch-related instead: https://docs.djangoproject.com/en/1.8/ref/models/querysets/#prefetch-related )
Commit pushed to master at https://github.com/mozilla/treeherder https://github.com/mozilla/treeherder/commit/c8c84e3d1a15dbe65e88e68d300a925e5322a2ba Bug 1196998 - Error adding exclusion profile after update to Django 1.8 We were calling select_related on a non-relational field. Only became an issue with Django 1.8.
:emorley the line you highlighted is defining a ManyToMany field. The `related_name` parameter is the name of the attribute the related class will use to refer to this one. I didn't know about the prefetch_related method, they must have added it in the last couple of versions of django :-)
(In reply to Mauro Doglio [:mdoglio] from comment #5) > :emorley the line you highlighted is defining a ManyToMany field. The > `related_name` parameter is the name of the attribute the related class will > use to refer to this one. I didn't know about the prefetch_related method, > they must have added it in the last couple of versions of django :-) I'm not sure I understand this reply? Do you mean the current fix here was correct, or not? (It actually doesn't use prefetch_related, it removes select_related entirely) :-)
I'm pretty sure just removing that was the right call. But feel free to double-check me, if I'm missing something. :) The self.exclusions.all() is fetching all the rows of the JobExclusion model. The field of ``info`` is in that model. It's not a foreign key or a m2m relation. It was just superfluous.
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.