pip install git+https://skycker@bitbucket.org/dvebukvy/sensei2.git@master
INSTALLED_APPS = (
...
'sensei2',
...
)
###Настройка
В `settings.py` проекта нужно определить два константы `SENSEI_PLUGINS` and `SENSEI_RULES`
Первая задает плагины и может быть пустой или отсутствовать. Вторая - обязательна и описывает как заполнять БД.
SENSEI_RULES = {
'topics': [
# {'app': 'web_site', 'model': 'TopicCategory', 'total': 1, 'presave_callback': lambda fields, rule, obj: tro(obj)},
{'app': 'web_site', 'model': 'TopicCategory', 'total': 1},
{'app': 'web_site', 'model': 'Topic', 'total': 1, 'plugins': {'title': 'sensei2.plugins.pretty_title'}}
],
'builders': [
{'app': 'web_site', 'model': 'Builder', 'total': 1,
'ignore': ['addresses', 'emails', 'web_sites', 'telephones']},
{'app': 'web_site', 'model': 'BuildAnnounce', 'total': 1}
],
'houses': [
{'app': 'web_site', 'model': 'HouseStatus', 'total': 1},
{'app': 'web_site', 'model': 'House', 'total': 3, 'override': {
'coordinates': lambda obj, field, sensei: '{0},{1}'.format(round(sensei.get_random_float(), 5),
round(sensei.get_random_float()), 5)}},
# {'app': 'web_site', 'model': 'Stage', 'total': 50},
# {'app': 'web_site', 'model': 'StageImage', 'total': 120}
],
'plans': [
{'app': 'web_site', 'model': 'FlatPlan', 'total': 300, 'ignore': ['total_price', 'total_area']},
{'app': 'web_site', 'model': 'FlatPlanParameter', 'total': 25},
{'app': 'web_site', 'model': 'Flat', 'total': 500},
]
}
###Использование
Как видите, правила заполнения разделены на группы, имя группы правил, которые нужно запустить,
передается аргументом менаджмент команды. Выполнение заполнения обернуто в декоратор `atomic` (работает одной транзакцией),
если что-то где-то падает, то в БД не записывается ничего для данной группы
./manage.py fill <rule_group_name>
Пример для объявления плагинов:
SENSEI_PLUGINS = ['sensei2.plugins.pretty_title', 'sensei2.plugins.independent_pretty_tittle']
### Расширенная документация
Полная документация доступна по ссылке http://wiki.dvebukvy.ru/page/42
Metadata
Release files for sensei2 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sensei2-1.1.2.tar.gz | 6.6 MB | Without provenance | Details for sensei2-1.1.2.tar.gz |
Release files / sensei2-1.1.2.tar.gz
| Download URL | sensei2-1.1.2.tar.gz |
|---|---|
| Size | 6.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be8025401022136987b23ab3cbf31bd0cd2bab5a0bd5c47c43ad3e2cea793ad6
|
|
BLAKE2b-256 checksum How to use checksums |
8af7e2305c3c5c786c106ee89d101e27b4b28aa885bd28c3661e2ea98ba325c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for sensei2 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.