Skip to content

Commit bc28de2

Browse files
committed
[Feat] skip proxy and abstract models
Close #11
1 parent 0b5b3fc commit bc28de2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

django_db_comments/db_comments.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ def copy_help_texts_to_database(
8989
return
9090

9191
app_config = apps.get_app_config(app_label)
92-
app_models = app_config.get_models()
92+
app_models = [
93+
app_model
94+
for app_model in app_config.get_models()
95+
if not any([app_model.abstract, app_model.proxy, not app_model.managed])
96+
]
9397

9498
columns_comments = {
9599
model._meta.db_table: get_comments_for_model(model) for model in app_models
@@ -100,7 +104,7 @@ def copy_help_texts_to_database(
100104

101105
table_comments = {
102106
model._meta.db_table: model._meta.verbose_name.title()
103-
for model in app_config.get_models()
107+
for model in app_models
104108
if model._meta.verbose_name
105109
}
106110

tests/test_db_comments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from mock import patch
1212
from psycopg2 import sql
1313

14-
from django.test import TestCase
1514
from django.db import models, DEFAULT_DB_ALIAS
15+
from django.test import TestCase
1616
try:
1717
from django.utils.translation import ugettext_lazy as _
1818
except ImportError:

0 commit comments

Comments
 (0)