Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search display 'Nothing found' #17

Open
IkaDeady opened this issue Jan 25, 2018 · 3 comments
Open

search display 'Nothing found' #17

IkaDeady opened this issue Jan 25, 2018 · 3 comments
Labels

Comments

@IkaDeady
Copy link

When I try to find an item on the field, nothing is found.
Django shows django.core.exceptions.FieldError: Related Field got invalid lookup: icontains
and the error seem to be at the line 27 on the view,
values = model.objects.filter(**{'{}__icontains'.format(search_field): value})[:limit]
I'm working with Django 2.0.1

@and3rson
Copy link
Owner

Thanks for reporting! I'll fix the Django 2.x support.

@and3rson
Copy link
Owner

@IkaDeady Can you please provide some example code on how you define your field? I could not reproduce it locally.

@and3rson and3rson added the bug label Jan 27, 2018
@IkaDeady
Copy link
Author

Models.py:
Class Time(models.Model):
some lines...
Class Meta:
abstract = True
Class Gateway(Time):
Serial = models.PositiveIntegerField(primary_key = True)
some lines....

Class Firmware(Time):
Serial = models.ManyToManyField(Gateway, blank = True, related_name = 'Gw_Serial')
Groups = models.ManyToManyField('Group', blank = True)
File = models.FileField(....arguments) 'I found that other peoples have similar issues with file fields'

Admin.py:
from searchableselect.widgets import SearchableSelect
other imports...

class formFix(forms.ModelForm):
class Meta:
model = Firmware
exclude = []
widgets = {
'Serial': SearchableSelect(model='fwupdate.Firmware', search_field='Serial', many=True, limit=10)
}

class FirmwareAdmin(admin.ModelAdmin):
form = formFix

admin.site.register(Firmware, FirmwareAdmin)

Tell me if you need more information.
PS: This widget can be used to multiple select like does with chosen.js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants