Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # blog/models.py
- from django.db import models
- from django.utils.translation import ugettext_lazy as _
- class PostCategory(models.Model):
- name = models.CharField(max_length=35)
- def __str__(self):
- return self.name
- class Meta:
- verbose_name = _('Posts\' category')
- verbose_name_plural = _('Posts\' categories')
- class Post(models.Model):
- title = models.CharField(_('Title'), max_length=200)
- content = models.TextField(_('Content'))
- category = models.ForeignKey(PostCategory)
- pub_date = models.DateTimeField(_('Publication date'))
- published = models.BooleanField(_('Is published?'), default=False)
- def __str__(self):
- return self.title
- class Meta:
- verbose_name = _('Post')
- verbose_name_plural = _('Posts')
- # blog/views.py
- from django.shortcuts import render
- from django.http import HttpResponse
- from django.utils.translation import ugettext as _
- from django.utils import translation
- def index(request):
- translation.activate("pl_PL")
- output = _('Posts') + '<br/>'
- output += translation.get_language()
- return HttpResponse(output)
- # excerpt from settings.py
- LANGUAGE_CODE = 'pl_PL'
- TIME_ZONE = 'Europe/Warsaw'
- USE_I18N = True
- USE_L10N = True
- USE_TZ = True
- LANGUAGES = (
- ('pl', _('Polish')),
- ('en', _('English')),
- )
- LOCALE_PATHS = (
- '/var/www/tmnd/locale/'
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement