On Thursday, February 20, 2014 4:58:59 PM UTC-4:30, Ivan Goncalves wrote:
>
> I have these two models below: 
>
> class business(models.Model):
>     name=models.CharField(max_length=40, blank=True, null=True)
>     
> class phone(models.Model):
>     business=models.ForeignKey(business, 
> verbose_name='Business',blank=False)    
>     phone=models.CharField(max_length=40, blank=True, null=True)
>
> in the admin.py
>
> class businessAdmin(admin.ModelAdmin):
>     model=business
>     search_fields = phone__phone
>
> How do we make this search work fine ? Ie, bring me all companies that 
> possess the phone number entered by the User in the search of the form 
> (Admin). ?
>

 Hello,

search_fields is a list of names (strings), so you must put:

search_fields = ['phone__phone']

You can also add more field names to this list for the search to include 
those fields. See your same example, working, here:
https://gist.github.com/camilotorresf/9143399

Regards,
Camilo 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/acab39de-87b6-460f-868f-ac5269782b49%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to