fork download
  1. from django.db import models
  2. from django.db.models import F
  3. # from django.contrib.auth.models import User
  4.  
  5.  
  6. class Video(models.Model):
  7. video = models.FileField(upload_to='video/%Y/%m/%d')
  8. rating = models.IntegerField(default=0)
  9.  
  10. @classmethod
  11. def change_rating(cls, pk, value):
  12. webm = cls.objects.get(pk=pk)
  13. webm.rating = F('rating' + value)
  14. webm.save()
  15.  
  16. @classmethod
  17. def increment_rating(cls, pk):
  18. cls.change_rating(pk, 1)
  19.  
  20. @classmethod
  21. def decrease_rating(cls, pk):
  22. cls.change_rating(pk, -1)
  23.  
Runtime error #stdin #stdout #stderr 0.02s 9944KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named 'django'