Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. def get_queryset(self):
  2. locale = get_language()
  3. return super().get_queryset().annotate(title=F('title_' + locale), body=F('body_' + locale),
  4. short_description=F('short_description_' + locale),
  5. seo_title=F('seo_title_' + locale))
  6.  
  7. title_uk = models.CharField(max_length=255, blank=False)
  8. title_en = models.CharField(max_length=255, blank=True)
  9. seo_title_uk = models.CharField(max_length=255, blank=True)
  10. seo_title_en = models.CharField(max_length=255, blank=True)
  11. short_description_uk = RichTextField(blank=False)
  12. short_description_en = RichTextField(blank=True)
  13. body_uk = RichTextField(blank=False)
  14. body_en = RichTextField(blank=True)
  15. created_at = models.DateTimeField(auto_now_add=True)
  16. published = models.BooleanField(default=False)
  17.  
  18. objects = NewsManager()
  19.  
  20. def get_queryset(self):
  21. return News.objects.all().exclude(published=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement