Advertisement
lobaev

Untitled

Apr 5th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. def fill_db(): # temporary метод для заполнения бд read-only данными
  2. usr1 = User.objects.create(nickname='Nikita1')
  3. usr2 = User.objects.create(nickname='Nikita2')
  4. tag1 = QuestionTag.objects.create(name='html', description='All about HTML')
  5. tag2 = QuestionTag.objects.create(name='xml', description='All about XML')
  6. tag3 = QuestionTag.objects.create(name='android', description='Android OS tag')
  7. q = Question.objects.create(author=usr1, title='Turn off auth in ubuntu 19.10 in all components',
  8. text='How is it possible to turn off authentication everytime when pc wakes up after '
  9. 'sleep? Im just really tired of it, I am often closing m '
  10. 'y pc and then opening again and everytime Ubuntu requires password.. I know that my '
  11. 'pc is used by me only and I don '
  12. 't need to care about my information safety. I have already turned off authentication '
  13. 'on pc boot. Now I am talking c '
  14. 'oncretically about the "Log in" state after pc sleeping.', pub_date=timezone.now())
  15. QuestionTags.objects.create(question=q, tag=tag3)
  16. QuestionTags.objects.create(question=q, tag=tag1)
  17. QuestionLikes.objects.create(question=q, author=usr2, like=True)
  18. CommentToQuestion.objects.create(text='Good question. I am interested!', pub_date=timezone.now(), author=usr2, question=q)
  19. ans = Answer.objects.create(text='I know the answer. It is ...', pub_date=timezone.now(), author=usr2, question=q)
  20. CommentToAnswer.objects.create(text='But this is comment of question author.', pub_date=timezone.now(), answer=ans, author=usr1)
  21. AnswerLikes.objects.create(answer=ans, author=usr1, like=False)
  22. q = Question.objects.create(author=usr2, title='Second question', text='bla bla bla', pub_date=timezone.now())
  23. QuestionTags.objects.create(question=q, tag=tag2)
  24. q = Question.objects.create(author=usr2, title='Third question', text='bla bla bla', pub_date=timezone.now())
  25. QuestionTags.objects.create(question=q, tag=tag3)
  26. q = Question.objects.create(author=usr1, title='Hello world', text='bla bla bla', pub_date=timezone.now())
  27. QuestionTags.objects.create(question=q, tag=tag2)
  28. QuestionTags.objects.create(question=q, tag=tag1)
  29. QuestionTags.objects.create(question=q, tag=tag3)
  30. QuestionLikes.objects.create(question=q, author=usr2, like=False)
  31. print("FILL_DB SUCCESS")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement