-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodels.py
More file actions
44 lines (35 loc) · 1.24 KB
/
Copy pathmodels.py
File metadata and controls
44 lines (35 loc) · 1.24 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
from django.db import models
from social.models import Profil, Topic
from django.utils import timezone
# Create your models here.
"""
model Content
"""
class Content(models.Model):
Profil = models.ForeignKey(Profil, on_delete=models.CASCADE, related_name="creator")
shares = models.ManyToManyField(Profil, through='Share')
likes = models.ManyToManyField(Profil, through='Like')
content = models.TextField(max_length=1000)
media = models.FileField(upload_to='uploads/%Y/%m/%d/', null=True, blank=True)
created_at = models.DateTimeField(default=timezone.now, editable=False)
update_at = models.DateTimeField(auto_now=True)
class Meta:
ordering = ['created_at']
abstract = True
verbose_name = 'content'
verbose_plural_name = "contents"
def __str__(self):
return self.content
"""
model Post
"""
class Post(Content):
topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
"""
model Like
"""
class Like(models.Model):
profil = models.ForeignKey(Profil, on_delete=models.CASCADE)
content = models.ForeignKey(Content, on_delete=models.CASCADE)
created_at = models.DateTimeField(default=timezone.now, editable=False)
update_at = models.DateTimeField(auto_now=True)