Skip to main content

django-text-manager - no more problems with texts for bots, websites, etc.

v0.1.1 - Basic functionality with api

v0.1.5 - Fixes of some bugs, new variable TEXT_MANAGER_DEFAULT_API_LANGUAGE in settings

Documentation

settings.py

INSTALLED_APPS = [
    ...
    "textmanager",
    ...
]

TEXT_MANAGER_EXTRA_LANGUAGES = ['uk'] # Optional, default languages when u add new text
TEXT_MANAGER_AVAILABLE_LANGUAGES = ['ru', 'uk', 'en'] # Optional, list of availbale languages in project 
TEXT_MANAGER_DEFAULT_API_LANGUAGE = 'en' # Optional, default language for api, fr. en to render english text if 'language' row in empty
TEXT_MANAGER_PERMISSION_CLASSES = ['rest_framework.permissions.IsAuthenticated',] # Optional, permission classes for api

How to add languages? (load in database 107 different languages)

python3 manage.py migrate
python3 manage.py loadlanguages

Usage

from textmanager.models import Text

text = Text.objects.get(unique_id='test').render(language="en", params={
    "var1": "friend"
})
print(text)

# >>> Hello, friend! - text in db: Hello, {{ var1 }}!

API

urls.py

from django.urls import path, include

urlpatterns = [
    path("textmanager/", include("textmanager.urls")),
]

how to send request?

import requests
import json
resp = requests.post(url="http://0.0.0.0:1234/textmanager/text/", json={
    "id": 5, # id or unique_id is required
    # or
    "unique_id": "test",

    "language": "en", # optional, default=None
    "render_with_jinja": False, # optional, default=true
    "params": {} # optional, default={}
}, headers={"Authorization": "Token ****"})
data = json.loads(resp.text)
print(data)

# >>> {'text': 'Hello, {{ var1 }}!'} # if language specified
# >>> {
#    'texts': [
#        {
#            'language': {
#                'alpha2': 'en', 
#                'alpha3_b': 'eng', 
#                'english_name': 'English', 
#                'language_name': 'English', 
#                'flag': '🇬🇧'
#            }, 
#            'text': 'Hello, {{ var1 }}!'
#        }, ...
#    ]
# }# if language is not specified

Metadata

Release files for django-text-manager 0.1.8

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-text-manager 0.1.8
File Size Uploaded Provenance
django_text_manager-0.1.8.tar.gz 15.5 kB Without provenance Details

Release files / django_text_manager-0.1.8.tar.gz

Download URL django_text_manager-0.1.8.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
588509530691e3e2f9ef770df6343c884a1ecec11e13ca3e5339b259b13deaac
BLAKE2b-256 checksum
How to use checksums
853e7bb2f296c696f6191e832d6778cd6a020d5c853f08925e5d7058e87f378e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Security for django-text-manager 0.1.8

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.

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