diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-12-22 15:18:51 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-12-22 15:18:51 +0000 |
| commit | ff60c5f9de3e8690d1e86f3e9e3f7248a15397c8 (patch) | |
| tree | a4cb0ebdd55fcaf8c8855231b6ad3e1a7bf45bee /django/contrib/admin/widgets.py | |
| parent | 7ef212af149540aa2da577a960d0d87029fd1514 (diff) | |
Fixed #1142 -- Added multiple database support.
This monster of a patch is the result of Alex Gaynor's 2009 Google Summer of Code project.
Congratulations to Alex for a job well done.
Big thanks also go to:
* Justin Bronn for keeping GIS in line with the changes,
* Karen Tracey and Jani Tiainen for their help testing Oracle support
* Brett Hoerner, Jon Loyens, and Craig Kimmerer for their feedback.
* Malcolm Treddinick for his guidance during the GSoC submission process.
* Simon Willison for driving the original design process
* Cal Henderson for complaining about ponies he wanted.
... and everyone else too numerous to mention that helped to bring this feature into fruition.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/contrib/admin/widgets.py')
| -rw-r--r-- | django/contrib/admin/widgets.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py index f0ecb384d4..0392b642bb 100644 --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -102,8 +102,9 @@ class ForeignKeyRawIdWidget(forms.TextInput): A Widget for displaying ForeignKeys in the "raw_id" interface rather than in a <select> box. """ - def __init__(self, rel, attrs=None): + def __init__(self, rel, attrs=None, using=None): self.rel = rel + self.db = using super(ForeignKeyRawIdWidget, self).__init__(attrs) def render(self, name, value, attrs=None): @@ -148,7 +149,7 @@ class ForeignKeyRawIdWidget(forms.TextInput): def label_for_value(self, value): key = self.rel.get_related_field().name - obj = self.rel.to._default_manager.get(**{key: value}) + obj = self.rel.to._default_manager.using(self.db).get(**{key: value}) return ' <strong>%s</strong>' % escape(truncate_words(obj, 14)) class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): @@ -156,8 +157,8 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): A Widget for displaying ManyToMany ids in the "raw_id" interface rather than in a <select multiple> box. """ - def __init__(self, rel, attrs=None): - super(ManyToManyRawIdWidget, self).__init__(rel, attrs) + def __init__(self, rel, attrs=None, using=None): + super(ManyToManyRawIdWidget, self).__init__(rel, attrs, using=None) def render(self, name, value, attrs=None): attrs['class'] = 'vManyToManyRawIdAdminField' |
