Powerful tool for truly synchronizing data and its relationships in database tables. Truly maps Foreign Keys and their on_delete rules in Django.
Project description
DjangoSyncMaster
Description
Powerful tool for truly synchronizing data and its relationships in database tables.
- Truly maps Foreign Keys and their on_delete rules in Django.
Django uses a migration system based on ORM (Object-Relational Mapping) to make changes to the database, However, this can become problematic when using Foreign Keys, since Django does not implement ON DELETE when synchronizing the database... This can be problematic if you want to change the data directly in the database.
This library aims to bring this automation to Django. When you perform a migration, the script will automatically read the tables created in models.py (ignoring any table that has not been declared outside of your app's models.py, this includes third-party tables and Django's own standards).
As soon as it performs a reading and separates the tables that were actually declared manually in models.py, it will create a map of your Foreign Keys and recreate them manually, one by one. With the configuration defined in your models.py.
This library aims to bring speed and automation to the development environment. (Not recommended for implementation environments)
This way, you won't need to edit a migration directly or modify the database by hand.
obs: I am not responsible for any type of data loss, as previously stated, this library aims to streamline the development environment and not to manage the implemented project.
How to use
- Install the package using pip:
pip install DjangoSyncMaster
- Add 'DjangoSyncMaster' to your Django app's apps.py file:
from django.apps import AppConfig
from django.conf import settings
from DjangoSyncMaster import sync_db
class AppNameConfig(AppConfig):
name = 'app_Name'
def ready(self):
from django.db.models.signals import post_migrate # await migrate
def handler(sender, **kwargs): # for pull Django instance info
sync_db(sender,db_settings=settings.DATABASES)
post_migrate.connect(handler, sender=self) #Execute function pos-migrate
- Make migrations
python manage.py makemigrations
python manage.py migrate
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file djangosyncmaster-1.0.2.tar.gz.
File metadata
- Download URL: djangosyncmaster-1.0.2.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f1d007a18ae829712364f0f3996a652fdc6095e94350f3b7a9d11ed349b2c0b
|
|
| MD5 |
48e9e936f38c20f3ff61c3241629d983
|
|
| BLAKE2b-256 |
0b2324356329a68a4995162b685b2f8ffbe2a24729d7c827660f15eb34274e34
|
File details
Details for the file djangosyncmaster-1.0.2-py3-none-any.whl.
File metadata
- Download URL: djangosyncmaster-1.0.2-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c56333cfe559472cfb4f2a0d8bb4566faa04fdaa92da7f143881ae1e242d10b3
|
|
| MD5 |
51b0bb6f62078c88933cc7939ded3f6c
|
|
| BLAKE2b-256 |
1d111cb201f2e5439cee16fadcf02e617a50a2f83807d3866da4b304bd764ad0
|