Tuesday, October 21, 2014

Reverse lookup in search_fields on Admin

Hello all!

I have this models:

class Article(models.Model):
  name = models.CharField(...)

class Sale(models.Model):
  ...

class SaleItems(models.Model):
  article = models.ForeignKey(Article)


And the Admin:
class SaleAdmin(admin.ModelAdmin):
  search_fields = ('...', < and here is the problem >

I want that in the Sale Index Page look all the sales that have sold the article "A"

To accomplished that I tried: 'saleitems__article__name' and it throws the following error:
"
Related Field got invalid lookup: icontains"

Is there a way to do the reverse lookup in search_fields?

Thanks id advance


--
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+unsubscribe@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/e84af525-53e7-4d4d-964b-ad36d5a6a20a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment