Guest User

Untitled

a guest
May 23rd, 2018
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #!/usr/bin/env python3.6.4
  2. # coding="UTF-8"
  3.  
  4. __author__ = 'Toran Sahu <toran.sahu@yahoo.com>'
  5. __copyright__ = 'Copyright (C) 2018 Ethereal Machines Pvt. Ltd. All rights reserved'
  6.  
  7.  
  8. from django.db import models
  9. from os import path
  10. from utils import directory_path_with_id
  11. from django.utils.text import slugify
  12. from django.db.models import Lookup, Transform
  13. from django.db.models.fields import Field, CharField
  14.  
  15.  
  16. # Create your models here.
  17.  
  18. class Image(models.Model):
  19. # image = models.CharField(blank=True, null=True, max_length=50)
  20. image = models.ImageField(blank=True, null=True, upload_to=directory_path_with_id)
  21.  
  22.  
  23. class Post(models.Model):
  24. title = models.CharField(max_length=50, unique=True)
  25. content = models.TextField()
  26. created_at = models.DateTimeField(auto_now_add=True)
  27. updated_at = models.DateTimeField(auto_now=True)
  28. thumbnail = models.ImageField(blank=True, null=True, upload_to=directory_path_with_id)
  29. images = models.ManyToManyField(Image, related_name='posts')
  30.  
  31. def __str__(self):
  32. return self.title
  33.  
  34. def get_slugged_title(self):
  35. return slugify(self.title)
Add Comment
Please, Sign In to add comment