fork download
  1. from django.db import models
  2. from django.utils import timezone
  3. from django.contrib.auth.models import User
  4.  
  5. class Post(models.Model):
  6. STATUS_CHOICES = (
  7. ('draft', 'Draft'),
  8. ('published', 'Published'),
  9. )
  10. title = models.CharField(max_length=250)
  11. slug = models.SlugField(max_length=250, unique_for_date='publish')
  12. author = models.ForeignKey(User, related_name='blog_posts')
  13. body = models.TextField()
  14. publish = models.DateTimeField(default=timezone.now)
  15. created = models.DateTimeField(auto_now_add=True)
  16. updated = models.DateTimeField(auto_now=True)
  17. status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft')
  18.  
  19. class Meta:
  20. ordering = ('-publish',)
  21.  
  22. def __str__(self):
  23. return self.title
  24.  
Runtime error #stdin #stdout #stderr 0.04s 9460KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
    from django.db import models
ImportError: No module named 'django'