Guest User

Untitled

a guest
Feb 21st, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. def kill_default(apps, schema_editor):
  2. User = apps.get_model('auth', 'User')
  3. Post = apps.get_model('articles', 'Post')
  4. Comment = apps.get_model('articles', 'Comment')
  5. user = User.objects.create_user(username='someus',
  6. email='someus@k.kf',
  7. password='qwertyuio',
  8. )
  9. user.save()
  10. for post in Post.objects.all():
  11. post.author = user
  12. post.save()
  13. post = Post.objects.create(title='aboutblah',
  14. full_text='blahisblahofblahunderblah',
  15. author=user)
  16. post.save()
  17. comment = Comment.objects.create(text='niceblahstination',
  18. post=post,
  19. author=user)
  20. comment.save()
  21.  
  22.  
  23. class Migration(migrations.Migration):
  24.  
  25. dependencies = [
  26. ('articles', '0006_auto_20171107_1626'),
  27. ]
  28.  
  29. operations = [
  30. migrations.RunPython(kill_default),
  31. ]
Add Comment
Please, Sign In to add comment