Opened 2 years ago

Closed 2 years ago

#33555 closed New feature (wontfix)

Enable Model Field choices to hold other Model objects as values of the iterable.

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 Mike Okoth)

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)

Change History (2)

comment:1 by Mike Okoth, 2 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 2 years ago

Resolution: wontfix
Status: newclosed

Thanks for this proposition, however it's really niche and probably not feasible, even if it's feasible I don't think there would be consensus to add that complexity. You can raise the idea on the DevelopersMailingList to reach a wider audience and see what other think.

Note: See TracTickets for help on using tickets.
Back to Top