Last active
October 15, 2017 10:19
-
-
Save aubricus/23217efdfe8a1a6539b2b873e4c1e665 to your computer and use it in GitHub Desktop.
De-Dupe / Return Draft DjangoCMS Plugin Instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See:
https://stackoverflow.com/a/30384714/1082663