Opened 10 years ago

Closed 10 years ago

#561 closed enhancement (duplicate)

Relate Objects to a choice of objects

Reported by: Boffbowsh Owned by: adrian
Component: Metasystem Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I have a object that needs to be related to one of a number objects. I propose two new field types called ForeignChoice and ManyToManyChoice (name suggestions welcomed, because I think they suck to be honest)

Proposed syntax:

from django.core import meta


class Component(meta.Model):
    name = meta.CharField(max_length=32)
    input = meta.ForeignChoice(COMPONENT_TYPES)

class TextInput(meta.Model):
    text = meta.TextField()

class ColourChoice(meta.Model):
    name = meta.SlugField(primary_key=True)
    rgb = meta.CharField(max_length=7)

This would create a appname_components table with the id and name fields as you'd expect, but also input_class and input_id fields. input_class would be one of 'TextInput' or 'ColourChoice', and input_id would refer to the PK in that class.

I'll start work on a patch soon, but ideas and comments would be very welcome

Change History (1)

comment:1 Changed 10 years ago by Boffbowsh

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #529

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