django-toggle-m2m-0.0.6
توضیحات
Django package for generating methods for toggling ManyToMany relationship entries in models
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | django-toggle-m2m-0.0.6 |
| نام | django-toggle-m2m |
| نسخه کتابخانه | 0.0.6 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Ventsislav Tashev |
| ایمیل نویسنده | wencakisa@gmail.com |
| آدرس صفحه اصلی | https://github.com/wencakisa/django-toggle-m2m |
| آدرس اینترنتی | https://pypi.org/project/django-toggle-m2m/ |
| مجوز | MIT |
# [django-toggle-m2m](https://pypi.org/project/django-toggle-m2m/)
## Installation
```bash
pip install django_toggle_m2m
```
## Usage in models
```python
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
```python
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
```bash
git clone https://github.com/wencakisa/django-toggle-m2m.git
pip install django_toggle_m2m
```
---
*Interesting fact* - https://code.djangoproject.com/ticket/20686
نیازمندی
| مقدار | نام |
|---|---|
| - | django |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6.0 | Python |
نحوه نصب
نصب پکیج whl django-toggle-m2m-0.0.6:
pip install django-toggle-m2m-0.0.6.whl
نصب پکیج tar.gz django-toggle-m2m-0.0.6:
pip install django-toggle-m2m-0.0.6.tar.gz