It seems like this should be possible, and this is the closest,
simplest
solution I can find in the documentation:
class InvoiceAdmin(admin.ModelAdmin):
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "books":
kwargs["queryset"] = Book.objects.filter(sold=False)
return db_field.formfield(**kwargs)
return super(InvoiceAdmin, self).formfield_for_foreignkey
(db_field, request, **kwargs)
But this does not work at all. I need to do this in many places
for a number of different forms, so it would be nice to be able
to specify the queryset for ForeignKey fields in a form without
completely recreating the admin form pages.
Thanks!
Walt
-~
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.