11from django .core .files .storage import default_storage
22from django .db import models
3+ from django_extensions .db .models import TimeStampedModel
34
45from users .models import Profile
56
@@ -21,28 +22,27 @@ class Meta:
2122 verbose_name_plural = "categories"
2223
2324
24- class PostImage (models . Model ):
25+ class PostImage (TimeStampedModel ):
2526 file = models .FileField (storage = default_storage , upload_to = IMAGE_BASE_PATH )
2627 description = models .CharField (max_length = 500 , blank = True )
2728
2829 def __str__ (self ):
2930 return self .file .name .lstrip (IMAGE_BASE_PATH )
3031
3132
32- class Clipping (models . Model ):
33+ class Clipping (TimeStampedModel ):
3334 id = models .BigAutoField (primary_key = True )
3435 title = models .CharField (max_length = 200 )
3536 description = models .CharField (max_length = 500 )
3637 link = models .URLField ()
3738 file = models .FileField (upload_to = "clipping_files/" )
38- created = models .DateTimeField (auto_now_add = True , editable = True )
39- updated = models .DateTimeField (auto_now = True , editable = True )
39+ display_date = models .DateField (db_index = True )
4040
4141 def __str__ (self ):
4242 return self .title
4343
4444
45- class Post (models . Model ):
45+ class Post (TimeStampedModel ):
4646 id = models .BigAutoField (primary_key = True )
4747 title = models .CharField (max_length = 200 )
4848 status = models .CharField (
@@ -56,8 +56,6 @@ class Post(models.Model):
5656 blank = True ,
5757 )
5858 body = models .TextField ()
59- created = models .DateTimeField (auto_now_add = True , editable = True )
60- updated = models .DateTimeField (auto_now = True , editable = True )
6159 categories = models .ManyToManyField (Category , related_name = "posts" , blank = True )
6260 images = models .ManyToManyField (PostImage , related_name = "posts" , blank = True )
6361
0 commit comments