Skip to content

Instantly share code, notes, and snippets.

@aubricus
Last active Oct 15, 2017
Embed
What would you like to do?
De-Dupe / Return Draft DjangoCMS Plugin Instances
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "my_plugin_fk":
kwargs["queryset"] = models.MyPluginModel.objects.filter(
Q(placeholder__static_draft__isnull=False) |
Q(placeholder__page__publisher_is_draft=True)
)
return super().formfield_for_foreignkey(db_field, request, **kwargs)
@aubricus

This comment has been minimized.

Copy link
Owner Author

@aubricus aubricus commented Oct 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment