Created
February 13, 2012 19:10
-
-
Save cooncesean/1819158 to your computer and use it in GitHub Desktop.
Creating an Ella Comment on a Topic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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