Skip to content

Commit

Permalink
add checks while registering a seeder to prevent redunduncy
Browse files Browse the repository at this point in the history
  • Loading branch information
suliman-99 committed Apr 21, 2024
1 parent c0ed98b commit ef51513
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions django_seeding/seeder_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def register(cls, seeder):
""" Method and decorator to register the seeder-class in the seeders list to be seeded when the server is run """
if not issubclass(seeder, Seeder):
raise TypeError('Only subclasses of Seeder class can be registered with SeederRegistry.register')

if seeder().get_id() in [obj.get_id() for obj in cls.seeders]:
return

cls.seeders.append(seeder())

@classmethod
Expand Down

0 comments on commit ef51513

Please sign in to comment.