Skip to main content

Типограф для Django

Project description

# Типограф для Django 1.7+

## Установка

` pip install django_typograph `

В settings.py INSTALLED_APPS добавить

` django_typograph `

## Использование

Импортировать

` from django_typograph.fields import TypographyField `

Добавить поле в модель



_text = models.TextField()
text = TypographyField(source="_text")


Выполнить миграции

## Пример модели


from django.db import models
from django_typograph.fields import TypographyField

class TestModel(models.Model):
title = models.CharField(max_length=200, verbose_name='Название')
_text = models.TextField()
text = TypographyField(source='_text')

def __unicode__(self):
return self.title

class Meta:
verbose_name = 'TestModel'




## Доступные настройки у поля TypographyField

* source - Из какого поля брать исходный код для типографии
* engine - Использовать другой движок для типографии именно у этого поля
* options - настройки для указанного движка. Если движок не указан, то настройки все равно будут применены к текущим



## Настройка
Для тонкой настройки нужно переопределить AppCfg приложения

Создайте файл:
```project_root/project_name/apps/django_typograph.py```

Со след. содержимым




from django_typograph.apps import DjangoTypographConfig


class CustomTypographConfig(DjangoTypographConfig):
engines = {
'EMT': {
'path': 'django_typograph.engine.EMT.driver.typography',
'options': {},
},
'EMT_SAFE': {
'path': 'django_typograph.engine.EMT.driver.typography',
'options': {
'OptAlign.all': 'off',
'OptAlign.oa_oquote': 'off',
'OptAlign.oa_obracket_coma': 'off',
'OptAlign.layout': 'off',
'Text.paragraphs': 'off',
'Text.auto_links': 'off',
'Text.breakline': 'off',
'Text.no_repeat_words': 'off',
}
}
}
default_engine = "EMT"

## Старые записи


Присутствует management команда type_records. Вся ее суть в том, что она просто пересохраняет текущих контент моделей у которых прописано поле TypographyField

---


А теперь рисуем сову собственно.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_typograph-0.1.4.tar.gz (33.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page