Created
April 8, 2017 19:24
-
-
Save vskrachkov/8885c0286634cfcb1da72e4076609d27 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 register_all(app_label): | |
"""Function for django admin. | |
Register all app models in django admin. | |
""" | |
from django.apps import apps | |
from django.contrib import admin | |
from django.contrib.admin.sites import AlreadyRegistered | |
app_models = apps.get_app_config(app_label).get_models() | |
for model in app_models: | |
try: | |
admin.site.register(model) | |
except AlreadyRegistered: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment