/docs/ref/contrib/comments/upgrade.txt
Plain Text | 78 lines | 57 code | 21 blank | 0 comment | 0 complexity | 35687d2ce1783a6089fea0d4ff13b173 MD5 | raw file
1=============================================== 2Upgrading from Django's previous comment system 3=============================================== 4 5Prior versions of Django included an outdated, undocumented comment system. Users who reverse-engineered this framework will need to upgrade to use the 6new comment system; this guide explains how. 7 8The main changes from the old system are: 9 10 * This new system is documented. 11 12 * It uses modern Django features like :doc:`forms </topics/forms/index>` and 13 :doc:`modelforms </topics/forms/modelforms>`. 14 15 * It has a single ``Comment`` model instead of separate ``FreeComment`` and 16 ``Comment`` models. 17 18 * Comments have "email" and "URL" fields. 19 20 * No ratings, photos and karma. This should only effect World Online. 21 22 * The ``{% comment_form %}`` tag no longer exists. Instead, there's now two 23 functions: ``{% get_comment_form %}``, which returns a form for posting a 24 new comment, and ``{% render_comment_form %}``, which renders said form 25 using the ``comments/form.html`` template. 26 27 * The way comments are include in your URLconf have changed; you'll need to 28 replace:: 29 30 (r'^comments/', include('django.contrib.comments.urls.comments')), 31 32 with:: 33 34 (r'^comments/', include('django.contrib.comments.urls')), 35 36Upgrading data 37-------------- 38 39The data models for Django's comment system have changed, as have the 40table names. Before you transfer your existing data into the new comments 41system, make sure that you have installed the new comments system as 42explained in the 43:doc:`quick start guide </ref/contrib/comments/index>`. 44This will ensure that the new tables have been properly created. 45 46To transfer your data into the new comments system, you'll need to directly 47run the following SQL: 48 49.. code-block:: sql 50 51 BEGIN; 52 53 INSERT INTO django_comments 54 (content_type_id, object_pk, site_id, user_name, user_email, user_url, 55 comment, submit_date, ip_address, is_public, is_removed) 56 SELECT 57 content_type_id, object_id, site_id, person_name, '', '', comment, 58 submit_date, ip_address, is_public, not approved 59 FROM comments_freecomment; 60 61 INSERT INTO django_comments 62 (content_type_id, object_pk, site_id, user_id, user_name, user_email, 63 user_url, comment, submit_date, ip_address, is_public, is_removed) 64 SELECT 65 content_type_id, object_id, site_id, user_id, '', '', '', comment, 66 submit_date, ip_address, is_public, is_removed 67 FROM comments_comment; 68 69 UPDATE django_comments SET user_name = ( 70 SELECT username FROM auth_user 71 WHERE django_comments.user_id = auth_user.id 72 ) WHERE django_comments.user_id is not NULL; 73 UPDATE django_comments SET user_email = ( 74 SELECT email FROM auth_user 75 WHERE django_comments.user_id = auth_user.id 76 ) WHERE django_comments.user_id is not NULL; 77 78 COMMIT;