mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Fixed #25985 -- Updated signature of ModelAdmin.formfield_for_* to make request a positional argument.
This commit is contained in:
parent
300de968d6
commit
dbb0df2a0e
4 changed files with 20 additions and 23 deletions
|
@ -571,15 +571,15 @@ multiple-database support::
|
|||
# Tell Django to look for objects on the 'other' database.
|
||||
return super(MultiDBModelAdmin, self).get_queryset(request).using(self.using)
|
||||
|
||||
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
|
||||
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
||||
# Tell Django to populate ForeignKey widgets using a query
|
||||
# on the 'other' database.
|
||||
return super(MultiDBModelAdmin, self).formfield_for_foreignkey(db_field, request=request, using=self.using, **kwargs)
|
||||
return super(MultiDBModelAdmin, self).formfield_for_foreignkey(db_field, request, using=self.using, **kwargs)
|
||||
|
||||
def formfield_for_manytomany(self, db_field, request=None, **kwargs):
|
||||
def formfield_for_manytomany(self, db_field, request, **kwargs):
|
||||
# Tell Django to populate ManyToMany widgets using a query
|
||||
# on the 'other' database.
|
||||
return super(MultiDBModelAdmin, self).formfield_for_manytomany(db_field, request=request, using=self.using, **kwargs)
|
||||
return super(MultiDBModelAdmin, self).formfield_for_manytomany(db_field, request, using=self.using, **kwargs)
|
||||
|
||||
The implementation provided here implements a multi-database strategy
|
||||
where all objects of a given type are stored on a specific database
|
||||
|
@ -596,15 +596,15 @@ Inlines can be handled in a similar fashion. They require three customized metho
|
|||
# Tell Django to look for inline objects on the 'other' database.
|
||||
return super(MultiDBTabularInline, self).get_queryset(request).using(self.using)
|
||||
|
||||
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
|
||||
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
||||
# Tell Django to populate ForeignKey widgets using a query
|
||||
# on the 'other' database.
|
||||
return super(MultiDBTabularInline, self).formfield_for_foreignkey(db_field, request=request, using=self.using, **kwargs)
|
||||
return super(MultiDBTabularInline, self).formfield_for_foreignkey(db_field, request, using=self.using, **kwargs)
|
||||
|
||||
def formfield_for_manytomany(self, db_field, request=None, **kwargs):
|
||||
def formfield_for_manytomany(self, db_field, request, **kwargs):
|
||||
# Tell Django to populate ManyToMany widgets using a query
|
||||
# on the 'other' database.
|
||||
return super(MultiDBTabularInline, self).formfield_for_manytomany(db_field, request=request, using=self.using, **kwargs)
|
||||
return super(MultiDBTabularInline, self).formfield_for_manytomany(db_field, request, using=self.using, **kwargs)
|
||||
|
||||
Once you've written your model admin definitions, they can be
|
||||
registered with any ``Admin`` instance::
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue