I recently had to migrate
django.contrib.comments from a legacy app to a newer app, also in Django. I only wanted to move relevant comments that were unflagged (no need to duplicate spam!)
Here’s how I did it (
manage.py shell usage):
from django.contrib.comments.models import Comment
from django.db.models import Count
from legacy.models import LegacyArticle
las = LegacyArticle.objects.all_published()
for la in las:
comments = Comment.objects.for_model(LegacyArticle).annotate(flagcount=Count('flags')).filter(object_pk=la.pk, flagcount=0)
# handler code...
When using the
data-* HTML5 attribute on elements, be careful not to use the
watch keyword as it’s a non-standard reserved object attribute in Mozilla browsers used for debugging.
From my testing, this only occurs when using older versions of jQuery <= 1.6.4. See my jsFiddle test for a working demo.
If you have a Django
forms.Form with two or more fields to validate that require information from each other you can test these in the forms’
However, if you need to test a condition that relies upon normal form data in addition to uploaded file data, the code below will let you do so; or see my Gist on GitHub.