Skip to main content

Django microframework allows you for easy synchronization of database entities between multiple django instances.

Project description

django-microframework

Django microframework allows you for easy synchronization of database entities between multiple django instances.

Requirements

  • Python (3.6, 3.7, 3.8)
  • Django (1.11, 2.0, 2.1, 2.2)

Installation

pip install django-microframework
python manage.py migrate

Usage

Sender

In your models.py file:

from microframework.sender import connect_signals
connect_signals([RegularModel, JSONModel, TreeModel, ForeignKeyModel], 'example_sender')

In your settings.py:

MICROFRAMEWORK_AMQP_URI = 'pyamqp://guest:guest@172.17.0.5'

Listener

Create service.py file:

from microframework.handler import DjangoObjectHandler, NamekoHandlerMeta
from example.models import RegularModel, JSONModel, TreeModel, ForeignKeyModel


class ListenerService(DjangoObjectHandler, metaclass=NamekoHandlerMeta):
    name = "listener_service"
    sender_name = "example_sender"
    synced_save_models = [RegularModel, JSONModel, TreeModel, ForeignKeyModel]

In your settings.py:

MICROFRAMEWORK_SERVICE_CLASS = "example.service:ListenerService"
MICROFRAMEWORK_AMQP_URI = 'pyamqp://guest:guest@172.17.0.5'

And add 'microframework' to your INSTALLED_APPS setting.

INSTALLED_APPS = [
    ...
    'microframework',
]

In your manage.py - this needs to be put before anything else in your code:

import eventlet
eventlet.monkey_patch()

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-microframework-0.1.0.tar.gz (5.0 kB view hashes)

Uploaded source

Built Distribution

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