troubleshooting.txt 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ===============
  2. Troubleshooting
  3. ===============
  4. This page contains some advice about errors and problems commonly encountered
  5. during the development of Django applications.
  6. .. _troubleshooting-django-admin:
  7. Problems running ``django-admin``
  8. =================================
  9. "command not found: `django-admin`"
  10. ------------------------------------
  11. :doc:`django-admin </ref/django-admin>` should be on your system path if you
  12. installed Django via ``python setup.py``. If it's not on your path, you can
  13. find it in ``site-packages/django/bin``, where ``site-packages`` is a directory
  14. within your Python installation. Consider symlinking to :doc:`django-admin
  15. </ref/django-admin>` from some place on your path, such as
  16. :file:`/usr/local/bin`.
  17. If ``django-admin`` doesn't work but ``django-admin.py`` does, you're probably
  18. using a version of Django that doesn't match the version of this documentation.
  19. ``django-admin`` is new in Django 1.7.
  20. Mac OS X permissions
  21. --------------------
  22. If you're using Mac OS X, you may see the message "permission denied" when
  23. you try to run ``django-admin``. This is because, on Unix-based systems like
  24. OS X, a file must be marked as "executable" before it can be run as a program.
  25. To do this, open Terminal.app and navigate (using the ``cd`` command) to the
  26. directory where :doc:`django-admin </ref/django-admin>` is installed, then
  27. run the command ``sudo chmod +x django-admin``.
  28. Miscellaneous
  29. =============
  30. I'm getting a ``UnicodeDecodeError``. What am I doing wrong?
  31. ------------------------------------------------------------
  32. This class of errors happen when a bytestring containing non-ASCII sequences is
  33. transformed into a Unicode string and the specified encoding is incorrect. The
  34. output generally looks like this::
  35. UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position ?:
  36. ordinal not in range(128)
  37. The resolution mostly depends on the context, however here are two common
  38. pitfalls producing this error:
  39. * Your system locale may be a default ASCII locale, like the "C" locale on
  40. UNIX-like systems (can be checked by the ``locale`` command). If it's the
  41. case, please refer to your system documentation to learn how you can change
  42. this to a UTF-8 locale.
  43. * You created raw bytestrings, which is easy to do on Python 2::
  44. my_string = 'café'
  45. Either use the ``u''`` prefix or even better, add the
  46. ``from __future__ import unicode_literals`` line at the top of your file
  47. so that your code will be compatible with Python 3.2 which doesn't support
  48. the ``u''`` prefix.
  49. Related resources:
  50. * :doc:`Unicode in Django </ref/unicode>`
  51. * https://wiki.python.org/moin/UnicodeDecodeError