fixtures.py 770 B

12345678910111213141516171819202122232425262728
  1. from django.utils.importlib import import_module
  2. def load_app_fixtures(app):
  3. """
  4. See if application has fixtures module defining load_fixtures function
  5. If it does, execute that function
  6. """
  7. app += '.fixtures'
  8. try:
  9. fixture = import_module(app)
  10. fixture.load_fixtures()
  11. return True
  12. except (ImportError, AttributeError):
  13. return False
  14. def update_app_fixtures(app):
  15. """
  16. See if application has fixtures module defining update_fixtures function
  17. If it does, execute that function
  18. """
  19. app += '.fixtures'
  20. try:
  21. fixture = import_module(app)
  22. fixture.update_fixtures()
  23. return True
  24. except (ImportError, AttributeError):
  25. return False