Guillaume
Guillaume

Reputation: 1

Django / Automatically retrieve models names

I'd like to retrieve automatically, in a loop, the names of the models located in a specific Django app inside my project. Does someone know how to do that ?

Best Regards

Guillaume

Upvotes: 0

Views: 100

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599610

from django.db import get_models, get_app

app = get_app('myappname')
models = get_models(app)

Upvotes: 3

Related Questions