Hello list, Newbie question: I wonder how I can filter or search lists by foreign keys. Assuming a 0.91 model like:
class Country( meta.Model): name = meta.CharField( _("Name"), maxlength=255) class City( meta.Model): name = meta.CharField( _("Name"), maxlength=255) country = meta.ForeignKey( Country) I would like to either search the city list by country, or to filter it. The difficulty here is that searches assume CharField behaviour, so just adding search_fields = ('country', ) predictably fails. Adding a list_filter has no effect whatsoever. Assuming that we have several thousand City rows, list drill-down becomes crucial for usability. (For the hypothetical example above, probably inline editing would be sufficient.) A hackish way of making the search work is to replace the table with a view and throw in some Postgres rules to handle inserts/updates etc. This works OK but it looks terrible and is hard to maintain because the Django DB magic cannot be used. Any other solution? A related note: When adding foreign keys to the list_display, sorting by clicking on the column header appears to be in order of the *numerical* foreign key rather than the display name. Any ideas how to get around this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---