property was added to news model
This commit is contained in:
parent
94bd07d31d
commit
9608fdb92a
|
|
@ -5,6 +5,7 @@ from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
from utils.models import BaseAttributes, TJSONField, TranslatedFieldsMixin
|
from utils.models import BaseAttributes, TJSONField, TranslatedFieldsMixin
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
|
||||||
|
|
||||||
class NewsType(models.Model):
|
class NewsType(models.Model):
|
||||||
|
|
@ -100,3 +101,21 @@ class News(BaseAttributes, TranslatedFieldsMixin):
|
||||||
@property
|
@property
|
||||||
def web_url(self):
|
def web_url(self):
|
||||||
return reverse('web:news:rud', kwargs={'slug': self.slug})
|
return reverse('web:news:rud', kwargs={'slug': self.slug})
|
||||||
|
|
||||||
|
@property
|
||||||
|
def list_also_like_news(self):
|
||||||
|
# news_content_type = ContentType.objects.get(app_label="news", model="news")
|
||||||
|
|
||||||
|
# tg_name = self.tags.filter(metadata__content_type=news_content_type)
|
||||||
|
|
||||||
|
# print(tg_name)
|
||||||
|
|
||||||
|
# tag_id = self.tags.all()
|
||||||
|
#
|
||||||
|
like_news = News.objects.filter(is_publish=True, news_type=self.news_type, tags__id=self.tags__id)
|
||||||
|
#
|
||||||
|
# print("LINE 112", like_news)
|
||||||
|
|
||||||
|
news_list = [self.description, "extra", "field", "test", self.slug]
|
||||||
|
|
||||||
|
return news_list
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ class NewsDetailSerializer(NewsBaseSerializer):
|
||||||
'is_publish',
|
'is_publish',
|
||||||
'author',
|
'author',
|
||||||
'country',
|
'country',
|
||||||
|
'list_also_like_news',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user