Created
January 13, 2017 13:05
-
-
Save jacqueswww/f4b1519328b7ea416ed42657da0cb00d to your computer and use it in GitHub Desktop.
Get all django models with FielFields attached to them.
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
from django.apps import apps | |
def get_models_with_file_fields(): | |
for model in apps.get_models(): | |
if any(field.__class__.__name__ in ('FileField', 'ImageField') | |
for field in model._meta.fields): | |
print(model) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment