#23710: ModelForm is not using the plain manager for foreign keys
-------------------------------------+-------------------------------------
Reporter: eagle-r | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):
* component: Uncategorized => Database layer (models, ORM)
Comment:
Collin, yes that's what's documented in the
[https://docs.djangoproject.com/en/1.7/topics/db/managers/#default-
managers default managers] docs.
I am not sure about this. The behavior doesn't seem to be well defined as
I couldn't find any documentation about this and no tests fail if I make
this change (please correct me if this is the wrong line; this is the
closest line I could find on stable/1.7.x to the one you referenced):
{{{
#!diff
diff --git a/django/db/models/fields/related.py
b/django/db/models/fields/related.py
index d87a922..0b4d726 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -1759,7 +1759,7 @@ class ForeignKey(ForeignObject):
(self.name, self.rel.to))
defaults = {
'form_class': forms.ModelChoiceField,
- 'queryset': self.rel.to._default_manager.using(db),
+ 'queryset': self.rel.to._base_manager.using(db),
'to_field_name': self.rel.field_name,
}
defaults.update(kwargs)
}}}
On the other hand, I could see the current behavior as expected and
changing it could cause problems for people relying on it.
--
Ticket URL: <https://code.djangoproject.com/ticket/23710#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.2e50c39c2dfe756f03b45b5d5efd7101%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.