Django package for generating methods for toggling ManyToMany relationship entries in models
Project description
django-toggle-m2m
Installation
pip install django_toggle_m2m
Usage in models
from django.db import models
from django_toggle_m2m.toggle import ToggleManyToMany
class Publication(models.Model):
title = models.CharField(max_length=32)
class Article(models.Model, ToggleManyToMany):
# ______________________^
# Extend ToggleManyToMany class
headline = models.CharField(max_length=256)
publications = models.ManyToManyField(Publication)
# Define M2M fields that are toggleable
TOGGLEABLE_FIELDS = ('publications',)
Relation toggling
article = Article.objects.create(...)
publication = Publication.objects.create(...)
article.toggle_publications(instance=publication) # Will be added
article.toggle_publications(instance=publication) # Will be removed
Development
git clone https://github.com/wencakisa/django-toggle-m2m.git
pip install django_toggle_m2m
Interesting fact - https://code.djangoproject.com/ticket/20686
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
Built Distribution
File details
Details for the file django_toggle_m2m-0.0.6.tar.gz
.
File metadata
- Download URL: django_toggle_m2m-0.0.6.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4b95d355d24e9838c6212acc641cd1817c0a7aad1d1f28c013e16947bc3ff0d |
|
MD5 | df03ac7d48e33fe005adeed10c91d40b |
|
BLAKE2b-256 | 38dfc33da1ef15c5c801912928c3ea26b288019203c1fef2005f566a7bb02daa |
File details
Details for the file django_toggle_m2m-0.0.6-py2.py3-none-any.whl
.
File metadata
- Download URL: django_toggle_m2m-0.0.6-py2.py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42f65bc9d437d19f3bd7e99daf1a35c29dea3914b49522f022ca0bafb6da4e72 |
|
MD5 | a7020cdc049ac1a7cf7e90df82def3ed |
|
BLAKE2b-256 | 455fc0df8b7821fc8d8dde4663836fc7137d984160a5f5a8b7478ed16c5a6a57 |