/README.rst

https://github.com/dcramer/django-data-tools · ReStructuredText · 48 lines · 32 code · 16 blank · 0 comment · 0 complexity · 12c3edf2f99e05c24a5cfa110e071797 MD5 · raw file

  1. django-data-tools
  2. =================
  3. A set of utilities and improvements for managing data (fixtures specifically) in Django.
  4. Install
  5. -------
  6. ::
  7. INSTALLED_APPS = (
  8. # ...
  9. 'datatools',
  10. )
  11. Commands
  12. --------
  13. dumpdata
  14. ~~~~~~~~
  15. An improved version of the ``manage.py dumpdata`` command:
  16. * Adds a --limit option to specify the maximum number of objects per model to fetch.
  17. * Adds a --sort option to specify ascending or descending order for serialization.
  18. * Automatically follows the dependency graph for ForeignKeys and ManyToManyFields.
  19. ::
  20. # Retrieve the latest 10000 thread objects with all their required dependencies
  21. python manage.py dumpdata forums.thread --limit=10000 --sort=desc
  22. Utilities
  23. ---------
  24. RangeQuerySetWrapper
  25. ~~~~~~~~~~~~~~~~~~~~
  26. Efficient iteration over a large collection of database objects, using a standard range
  27. pattern on the primary key.
  28. ::
  29. from datatools.query import RangeQuerySetWrapper
  30. qs = RangeQuerySetWrapper(Model.objects.all(), limit=100000)
  31. for obj in qs:
  32. print "Got %r!" % obj