compat.py 684 B

12345678910111213141516171819202122232425
  1. # flake8: noqa
  2. try:
  3. import json
  4. except ImportError:
  5. from django.utils import simplejson as json
  6. try:
  7. from django.contrib.auth import get_user_model
  8. except ImportError:
  9. from django.contrib.auth.models import User
  10. else:
  11. User = get_user_model()
  12. try:
  13. from django.utils.encoding import smart_text
  14. except ImportError:
  15. from django.utils.encoding import smart_unicode as smart_text
  16. try:
  17. # In 1.5 the test client uses force_bytes
  18. from django.utils.encoding import force_bytes as force_bytes_or_smart_bytes
  19. except ImportError:
  20. # In 1.4 the test client just uses smart_str
  21. from django.utils.encoding import smart_str as force_bytes_or_smart_bytes