Esempio n. 1
0
 def save(self, user):
     with transaction.atomic():
         topic = Topic()
         topic.user = user
         topic.title = self.cleaned_data['topic']
         topic.save()
         message = Message()
         message.user = user
         message.content = self.cleaned_data['content']
         message.topic = topic
         message.save()
         return topic, message
Esempio n. 2
0
def generate_sampledata(options):
    threads = int(options.get('thread_count', 10))
    posts = int(options.get('post_count', 10))
    user = User.objects.get(pk=1)

    for m in xrange(0, threads):
        topic = Topic()
        topic.title = u'Lorem ipsum dolor sit amet'
        topic.user = user
        topic.save()
        for k in xrange(0, posts):
            message = Message()
            message.topic = topic
            message.user = user
            message.content = u'Lorem Ipsum dolor sit amet <a href="asdasd">aasdasdasd</a>'
            message.save()