profile/management/commands/seed_db.py
changeset 43 20f411241654
parent 41 d84a3781b979
child 65 41fcf2273003
equal deleted inserted replaced
42:a3a44b21845d 43:20f411241654
     3 from django.core.management.base import NoArgsCommand
     3 from django.core.management.base import NoArgsCommand
     4 
     4 
     5 from django.contrib.auth.models import User
     5 from django.contrib.auth.models import User
     6 
     6 
     7 from pytask.profile.models import Profile, Notification
     7 from pytask.profile.models import Profile, Notification
       
     8 from pytask.utils import make_key
     8 
     9 
     9 def seed_db():
    10 def seed_db():
    10     """ a method to seed the database with random data """
    11     """ a method to seed the database with random data """
    11     
    12     
    12     
    13     
    44 
    45 
    45     for i in range(10):
    46     for i in range(10):
    46         Notification(sent_to=new_user, sent_date=datetime.now(), 
    47         Notification(sent_to=new_user, sent_date=datetime.now(), 
    47                      subject="A subject here for"+str(i),
    48                      subject="A subject here for"+str(i),
    48                      message="A message with mess"+str(i)+" html inside.\
    49                      message="A message with mess"+str(i)+" html inside.\
    49                      <br /><b>a bold text</b>"
    50                      <br /><b>a bold text</b>",
       
    51                      uniq_key=make_key(Notification),
    50                     ).save()
    52                     ).save()
    51 
    53 
    52 class Command(NoArgsCommand):
    54 class Command(NoArgsCommand):
    53     
    55     
    54     def handle_noargs(self, **options):
    56     def handle_noargs(self, **options):