@@ -356,30 +356,25 @@ def register_django_pghistory_models():
356356 # don't specifically cover proxy models for auto-generated ManyToMany through tables.
357357 # This is a common pattern used by libraries like django-pghistory and is necessary
358358 # because accessing Model.field.through at module import time triggers AppRegistryNotReady.
359- try :
360- FindingReviewers = apps .get_model ("dojo" , "FindingReviewers" )
361- except LookupError :
362- # Model doesn't exist yet, create it
363- # Note: Finding is imported above, and apps registry is ready when this runs
364- reviewers_through = Finding ._meta .get_field ("reviewers" ).remote_field .through
365-
366- class FindingReviewers (reviewers_through ):
367- class Meta :
368- proxy = True
369-
370- pghistory .track (
371- pghistory .InsertEvent (),
372- pghistory .DeleteEvent (),
373- pghistory .ManualEvent (label = "initial_backfill" ),
374- meta = {
375- "db_table" : "dojo_finding_reviewersevent" ,
376- "indexes" : [
377- models .Index (fields = ["pgh_created_at" ]),
378- models .Index (fields = ["pgh_label" ]),
379- models .Index (fields = ["pgh_context_id" ]),
380- ],
381- },
382- )(FindingReviewers )
359+ reviewers_through = Finding ._meta .get_field ("reviewers" ).remote_field .through
360+
361+ class FindingReviewers (reviewers_through ):
362+ class Meta :
363+ proxy = True
364+
365+ pghistory .track (
366+ pghistory .InsertEvent (),
367+ pghistory .DeleteEvent (),
368+ pghistory .ManualEvent (label = "initial_backfill" ),
369+ meta = {
370+ "db_table" : "dojo_finding_reviewersevent" ,
371+ "indexes" : [
372+ models .Index (fields = ["pgh_created_at" ]),
373+ models .Index (fields = ["pgh_label" ]),
374+ models .Index (fields = ["pgh_context_id" ]),
375+ ],
376+ },
377+ )(FindingReviewers )
383378
384379 # Only log during actual application startup, not during shell commands
385380 if "shell" not in sys .argv :
0 commit comments