Forwarded from Tarjima Kinolar Uzmovi
Please open Telegram to view this post
VIEW IN TELEGRAM
Forwarded from Tarjima Kinolar Uzmovi
Please open Telegram to view this post
VIEW IN TELEGRAM
Forwarded from Abdulaziz 🌙 Baxriddinov
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
class Post(models.Model):
STATUS_CHOICES = (
('draft', 'Draft'),
('published', 'Published'),
)
title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250, unique_for_date='publish')
author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts')
photo = models.ImageField(upload_to='blog/%Y/%m/%d/', blank=True)
body = models.TextField()
publish = models.DateTimeField(default = timezone.now)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft')
class Meta:
ordering = ('-publish',)
def str(self):
return self.title
from django.utils import timezone
from django.contrib.auth.models import User
class Post(models.Model):
STATUS_CHOICES = (
('draft', 'Draft'),
('published', 'Published'),
)
title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250, unique_for_date='publish')
author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts')
photo = models.ImageField(upload_to='blog/%Y/%m/%d/', blank=True)
body = models.TextField()
publish = models.DateTimeField(default = timezone.now)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft')
class Meta:
ordering = ('-publish',)
def str(self):
return self.title
Forwarded from Abdulaziz 🌙 Baxriddinov
models.py
856 B