upgrade.txt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. .. _ref-contrib-comments-upgrade:
  2. ===============================================
  3. Upgrading from Django's previous comment system
  4. ===============================================
  5. Prior versions of Django included an outdated, undocumented comment system. Users who reverse-engineered this framework will need to upgrade to use the
  6. new comment system; this guide explains how.
  7. The main changes from the old system are:
  8. * This new system is documented.
  9. * It uses modern Django features like :ref:`forms <topics-forms-index>` and
  10. :ref:`modelforms <topics-forms-modelforms>`.
  11. * It has a single ``Comment`` model instead of separate ``FreeComment`` and
  12. ``Comment`` models.
  13. * Comments have "email" and "URL" fields.
  14. * No ratings, photos and karma. This should only effect World Online.
  15. * The ``{% comment_form %}`` tag no longer exists. Instead, there's now two
  16. functions: ``{% get_comment_form %}``, which returns a form for posting a
  17. new comment, and ``{% render_comment_form %}``, which renders said form
  18. using the ``comments/form.html`` template.
  19. Upgrading data
  20. --------------
  21. The data models have changed, as have the table names. To transfer your data into the new system, you'll need to directly run the following SQL:
  22. .. code-block:: sql
  23. BEGIN;
  24. INSERT INTO django_comments
  25. (content_type_id, object_pk, site_id, user_name, user_email, user_url,
  26. comment, submit_date, ip_address, is_public, is_removed)
  27. SELECT
  28. content_type_id, object_id, site_id, person_name, '', '', comment,
  29. submit_date, ip_address, is_public, approved
  30. FROM comments_freecomment;
  31. INSERT INTO django_comments
  32. (content_type_id, object_pk, site_id, user_id, comment, submit_date,
  33. ip_address, is_public, is_removed)
  34. SELECT
  35. content_type_id, object_id, site_id, user_id, comment, submit_date,
  36. ip_address, is_public, is_removed
  37. FROM comments_comment;
  38. UPDATE django_comments SET user_name = (
  39. SELECT username FROM auth_user
  40. WHERE django_comments.user_id = auth_user.id
  41. );
  42. UPDATE django_comments SET user_email = (
  43. SELECT email FROM auth_user
  44. WHERE django_comments.user_id = auth_user.id
  45. );
  46. COMMIT;