irongit

Smart enough to know if your model exists

huncholanehuncholaneauthored
parent 98ae0fbcommit 9c16251fa7b56d9d3de937783c1479cb288dc495Browse files

1 file changed, +2 -1

+2-1rango/backend/api/management/commands/createapi.py
@@ -26,7 +26,8 @@ class Command(BaseCommand):
2626 }
2727 # If the api model does not exist raise a CommandError
2828 try:
29- __import__(f'{root_dir}.models.{model_name}')
29+ # Test if the model exists
30+ getattr(__import__(root_dir).models, model_name)
3031 except:
3132 raise CommandError(f"Model {model_name} does not exist")
3233 # If the root directory does not exist raise a CommandError