Opened 4 years ago
Last modified 4 years ago
#33555 closed New feature
Enable Model Field choices to hold other Model objects as values of the iterable. — at Version 1
| Reported by: | Mike Okoth | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 4.0 |
| Severity: | Normal | Keywords: | choices option for model objects |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Allow for something like:
from django.db import models
from django.utils.translation import ugettext_lazy as _
from Documents.models import Document
from Comments.models import Comment
class Notification(models.Model):
ENTITY = (
(Document , _('Notification on Document')),
(Comment , _('Notification on Comment')),
)
notificationBelongsTo = models.OneToOneField(choices=ENTITY,default= Document, on_delete=Models.CASCADE)
This would allow for an option to choose the relation from a list of objects(that are in this case related models)
Note:
See TracTickets
for help on using tickets.