Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. from polls.models import Word, Results
  2.  
  3. def detail(request):
  4. q = Word(type="How do you like")
  5. q.save()
  6. Word.objects.get(pk=1)
  7.  
  8. q.score_set.create(score=5)
  9. q.score_set.create(score=4)
  10. q.score_set.create(score=3)
  11. q.score_set.create(score=2)
  12. q.score_set.create(score=1)
  13.  
  14.  
  15. return render_to_response('/$')
  16.  
  17. from django.db import models
  18.  
  19.  
  20. class Word(models.Model):
  21. type = models.CharField(max_length=200)
  22.  
  23. def __unicode__(self):
  24. return self.type
  25.  
  26. class Results(models.Model):
  27. word = models.ForeignKey(Word)
  28. score = models.IntegerField()
  29.  
  30. def __unicode__(self):
  31. return self.score
  32.  
  33. IntegrityError at /
  34. polls_word.score may not be NULLRequest Method: GET
  35. Request URL: Django Version: 1.4.1
  36. Exception Type: IntegrityError
  37. Exception Value: polls_word.score may not be NULL
  38. Exception Location: /home/oveledar/.virtualenvs/django/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py in execute, line 337
  39. Python Executable: /home/oveledar/.virtualenvs/django/bin/python
  40. Python Version: 2.6.6
  41. Python Path: ['/home/oveledar/django/mysite',
  42. '/home/oveledar/.virtualenvs/django/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg',
  43. '/home/oveledar/.virtualenvs/django/lib/python2.6/site-packages/pip-1.0.2-py2.6.egg',
  44. '/home/oveledar/.virtualenvs/django/lib64/python26.zip',
  45. '/home/oveledar/.virtualenvs/django/lib64/python2.6',
  46. '/home/oveledar/.virtualenvs/django/lib64/python2.6/plat-linux2',
  47. '/home/oveledar/.virtualenvs/django/lib64/python2.6/lib-tk',
  48. '/home/oveledar/.virtualenvs/django/lib64/python2.6/lib-old',
  49. '/home/oveledar/.virtualenvs/django/lib64/python2.6/lib-dynload',
  50. '/usr/lib/python2.6',
  51. '/usr/lib64/python2.6',
  52. '/home/oveledar/.virtualenvs/django/lib/python2.6/site-packages']
  53.  
  54. class Results(models.Model):
  55. word = models.ForeignKey(Word)
  56. score = models.IntegerField(blank=True, null=True)
  57.  
  58. python manange.py syncdb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement