Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3.6.4
- # coding="UTF-8"
- __author__ = 'Toran Sahu <toran.sahu@yahoo.com>'
- __copyright__ = 'Copyright (C) 2018 Ethereal Machines Pvt. Ltd. All rights reserved'
- from django.db import models
- from os import path
- from utils import directory_path_with_id
- from django.utils.text import slugify
- from django.db.models import Lookup, Transform
- from django.db.models.fields import Field, CharField
- # Create your models here.
- class Image(models.Model):
- # image = models.CharField(blank=True, null=True, max_length=50)
- image = models.ImageField(blank=True, null=True, upload_to=directory_path_with_id)
- class Post(models.Model):
- title = models.CharField(max_length=50, unique=True)
- content = models.TextField()
- created_at = models.DateTimeField(auto_now_add=True)
- updated_at = models.DateTimeField(auto_now=True)
- thumbnail = models.ImageField(blank=True, null=True, upload_to=directory_path_with_id)
- images = models.ManyToManyField(Image, related_name='posts')
- def __str__(self):
- return self.title
- def get_slugged_title(self):
- return slugify(self.title)
Add Comment
Please, Sign In to add comment