Skip to main content
# Типограф для 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

---


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

Release files for django_typograph 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django_typograph 0.1.4
File Size Uploaded
django_typograph-0.1.4.tar.gz 33.5 kB Details

Release files / django_typograph-0.1.4.tar.gz

Download URL django_typograph-0.1.4.tar.gz
Size 33.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5bf4f5c9d4c6be8cb9a499c552813ce2ea0fae5cb21e76dcb05cef545da09d9f
BLAKE2b-256 checksum
How to use checksums
97cc0b2247b737b833366c6fe02583dcfc11f80f5f7ff7fe3558c6920acdb20d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page