Skip to content

Instantly share code, notes, and snippets.

@cooncesean
Created February 13, 2012 19:10
Show Gist options
  • Save cooncesean/1819158 to your computer and use it in GitHub Desktop.
Save cooncesean/1819158 to your computer and use it in GitHub Desktop.
Creating an Ella Comment on a Topic
from django.contrib import comments
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.contrib.contenttypes.models import ContentType
from django.contrib.webdesign.lorem_ipsum import sentence
from scout.topics.models import Topic
def create_comments(obj, number_of_comments=5):
for i in range(0, number_of_comments):
c = comments.get_model().objects.create(
comment=sentence(),
user=User.objects.latest('id'),
site=Site.objects.get_current(),
content_type=ContentType.objects.get_for_model(obj),
object_pk=obj.id
)
print 'Created Comment: %d - %s' % (c.id, c.comment)
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment