forked from gnyylmz/BlogProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
56 lines (46 loc) · 2.16 KB
/
models.py
File metadata and controls
56 lines (46 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from django.db import models
from ckeditor.fields import RichTextField
from imagekit.models import ProcessedImageField
from imagekit.processors import ResizeToFill
from uuslug import slugify
# Create your models here.
class category(models.Model):
category_name = models.CharField(max_length=50,null=True)
category_keywords = models.CharField(max_length=500,null=True)
category_description = models.CharField(max_length=500,null=True)
category_icon = models.CharField(max_length=100,null=True)
seo_url = models.CharField(max_length=500,unique=True, null=True, blank=True,verbose_name='Seo_URL : (Otomatik doldurur)')
class Meta:
verbose_name_plural = "Kategoriler"
def __str__(self):
return '{}'.format(self.category_name)
def save(self, *args, **kwargs):
self.seo_url = slugify(self.category_name)
super(category, self).save(*args, **kwargs)
class post(models.Model):
title = models.CharField(max_length=500,null=True)
time = models.DateTimeField(auto_now=False,null=True)
content = RichTextField(null=True)
keywords = models.CharField(max_length=500,null=True)
description = models.CharField(max_length=500,null=True)
image = ProcessedImageField(upload_to='blog_img',
options={'quality': 70},null=True)
category_list = models.ForeignKey(category,null=True)
seo_url = models.CharField(max_length=500,unique=True, null=True, blank=True,verbose_name='Seo_URL : (Otomatik doldurur)')
is_active = models.BooleanField(default=False)
class Meta:
verbose_name_plural = "Blog Yaz"
def __str__(self):
return '{}'.format(self.title)
def save(self, *args, **kwargs):
self.seo_url = slugify(self.title)
super(post, self).save(*args, **kwargs)
class content_media(models.Model):
blog = models.ForeignKey(post)
image = ProcessedImageField(upload_to='blog_img',
format='JPEG',
options={'quality': 70},null=True)
class Meta:
verbose_name_plural = "Resim Ekle"
def __str__(self):
return '{}'.format(self.blog.title)