Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions djorm_pgfulltext/management/commands/update_search_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

class Command(BaseCommand):
help = 'Update search fields'
args = "appname [model]"
args = "appname [model] [using]"

def handle(self, app=None, model=None, **options):
def handle(self, app=None, model=None, using='default', **options):
if not app:
raise CommandError("You must provide an app to update search fields.")

Expand Down Expand Up @@ -46,5 +46,5 @@ def handle(self, app=None, model=None, **options):

for m in app_models_for_process:
print("Processing model %s..." % m, end='')
m._fts_manager.update_search_field()
m._fts_manager.update_search_field(using=using)
print("Done")
7 changes: 6 additions & 1 deletion djorm_pgfulltext/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ def __exit__(self, *args, **kwargs):


def auto_update_search_field_handler(sender, instance, *args, **kwargs):
instance.update_search_field()
# to take using from method save()
defaults = {'using': 'default'}

instance.update_search_field(
**{arg: kwargs.get(arg, defaults[arg]) for arg in defaults.keys()}
)


class SearchManagerMixIn(object):
Expand Down