Skip to content

Latest commit

 

History

History
146 lines (97 loc) · 3.01 KB

File metadata and controls

146 lines (97 loc) · 3.01 KB

Django Tilda

На русском

Downloads

Warning! Before start you have to register in tilda.cc and have “Tilda Business” account for use Tilda API.

Synchronization available only for published in Project pages.

Supported versions

  • Django >= 4.2
  • Python >= 3.9

Older Django/Python? Use django-tilda<2.0.

Screenshots

Screenshot

Screenshot

Quick-Start Guide

  1. Install Django Tilda:
pip install django-tilda
  1. Add to your INSTALLED_APPS:
'django_object_actions',
'tilda',
  1. Add in settings.py params:

TILDA_PUBLIC_KEY and TILDA_SECRET_KEY generated in Business account Tilda.cc — https://tilda.cc/identity/apikeys/

TILDA_PROJECTID — you need to have exist project in Tilda.cc (look at your location bar when you work with project in Tilda panel)

TILDA_MEDIA_IMAGES_URL — your url path for folder in TILDA_MEDIA_IMAGES

TILDA_PUBLIC_KEY = ''
TILDA_SECRET_KEY = ''
TILDA_PROJECTID = ''
TILDA_MEDIA_IMAGES_URL = '/media/tilda/images'
TILDA_MEDIA_IMAGES = os.path.join(BASE_DIR, 'media/tilda/images')
TILDA_MEDIA_JS = os.path.join(BASE_DIR, 'media/tilda/js')
TILDA_MEDIA_CSS = os.path.join(BASE_DIR, 'media/tilda/css')

Optional settings:

TILDA_TIMEOUT = 10  # Tilda API request timeout, seconds
TILDA_MEDIA_CSS_URL = '/media/tilda/css'
TILDA_MEDIA_JS_URL = '/media/tilda/js'
  1. TILDA_MEDIA_IMAGES, TILDA_MEDIA_JS, TILDA_MEDIA_CSS — create this folders manually
  2. Migrate python manage.py migrate

Done!

Upgrading from 1.x

Version 2.0 requires Django >= 4.2 / Python >= 3.9 and stores page assets in JSONField. Run python manage.py migrate tilda — existing data is converted automatically.

Usage

Simple example:

models.py

from django.db import models
from tilda import TildaPageField


class Page(models.Model):

    title = models.CharField(
        u'Title',
        max_length=100
    )

    tilda_content = TildaPageField(
        verbose_name=u'Tilda Page'
    )

    created = models.DateTimeField(
        u'Created',
        auto_now_add=True
    )

template (object — instance of Page class)

<head>
    ...
    {% for css in object.tilda_content.get_css_list %}
        <link rel="stylesheet" href="{{ css }}">
    {% endfor %}
    ...
</head>

<body>
    ...
    {{ object.tilda_content.html|safe }}
    ...
    {% for js in object.tilda_content.get_js_list %}
        <script src="{{ js }}"></script>
    {% endfor %}
</body>

Localizations

  • English
  • Русский