Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#327 closed defect (fixed)

Metasystem should support more than one ManyToMany relationship

Reported by: upadhyay@… 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:


with the following model:

class User(meta.Model):
    fields = (
        meta.CharField('email', maxlength=200),

class Book(meta.Model):
    fields = (
        meta.CharField('title', maxlength=200),
        meta.ManyToManyField(User, rel_name="owner", related_name="owns"),
        meta.ManyToManyField(User, rel_name="seeker", related_name="seeks"),

I am getting only one relation exposed in the generated api:

>>> from django.models.testmany import *
>>> u = users.User(email="asd")
>>> dir(u)
['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__getattribute__'
, '__hash__', '__init__', '__metaclass__', '__module__', '__new__', '__reduce__'
, '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_meta',
 'delete', 'email', 'get_owns', 'get_owns_count', 'get_owns_list', 'id', 'save',

also book gets APIs for getting books "owner" and "seeker" relationships, but there is no corresponding "set_owners" and "set_seekers" functions, only a set_users:

>>> b = books.Book(title="asdads")
>>> dir(b)
['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__getattribute__'
, '__hash__', '__init__', '__metaclass__', '__module__', '__new__', '__reduce__'
, '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_meta',
 'delete', 'get_owner_list', 'get_seeker_list', 'id', 'save', 'set_users', 'titl

I am using Python 2.3, latest django from SVN.

Change History (6)

comment:1 Changed 11 years ago by adrian

  • Summary changed from More than one ManyToMany relationship broken to Metasystem should support more than one ManyToMany relationship

comment:2 Changed 11 years ago by adrian

  • Component changed from Core framework to Metasystem

comment:3 Changed 11 years ago by adrian

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

This was fixed in the model syntax change.

comment:4 Changed 11 years ago by L.Plant.98@…

  • Resolution fixed deleted
  • Status changed from closed to reopened

In the new syntax, there doesn't seem to be rel_name keyword argument, and the docs don't indicate anything else:

from django.core import meta

class User(meta.Model):
  email = meta.CharField('email', maxlength=200)

class Book(meta.Model):
  title = meta.CharField('title', maxlength=200),
  owner = meta.ManyToManyField(User, rel_name="owner", related_name="owns")
  seeker = meta.ManyToManyField(User, rel_name="seeker", related_name="seeks")


TypeError: __init__() got an unexpected keyword argument 'rel_name'

Without that argument, I get this:

>>> dir(books.Book(title='A title'))
['__class__', '__delattr__', '__dict__', '__doc__', '__eq__
', '__getattribute__', '__hash__', '__init__', '__metaclass
__', '__module__', '__new__', '__reduce__', '__reduce_ex__'
, '__repr__', '__setattr__', '__str__', '__weakref__', '_me
ta', 'delete', 'get_user_list', 'id', 'save', 'set_owner', 
'set_seeker', 'title']

i.e. a single method 'get_user_list', when I would need 'get_seeker_list' and 'get_owner_list'. So this bug still appears to be valid with subversion 632 (2005-09-10)

comment:5 Changed 11 years ago by anonymous

  • Resolution set to fixed
  • Status changed from reopened to closed

Aha, just found the ModelSyntaxChangeInstructions. The 'singular' keyword argument is not very well documented...
It works if you do this:

class Book(meta.Model):
  title = meta.CharField('title', maxlength=200)
  owner = meta.ManyToManyField(User, singular = "owner", related_name="owns")
  seeker = meta.ManyToManyField(User, singular = "seeker", related_name="seeks")

comment:6 Changed 9 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

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