Modify

Ticket #454 (closed defect: worksforme)

Opened 4 years ago

Last modified 4 years ago

ManyToMany Self Referential Doesn't get is_hidden Set

Reported by: mtrier@… Owned by: andrew
Priority: major Milestone: 0.7.2
Component: migrations Version: 0.7
Keywords: Cc:

Description

I have a Self Referential ManyToManyField?. When validating the models this field comes in as self.rel.is_hidden() == True. When using South's schemamigration this field comes in with self.rel.is_hidden() == None causing the line:

setattr(cls, related.get_accessor_name(), ManyRelatedObjectsDescriptor(related))

The issue is the related.get_accessor_name() returns None since there is no accessor.

Traceback (most recent call last):
  File "./manage.py", line 13, in <module>
    execute_manager(settings)
  File "/Users/mtrier/dev/django/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/Users/mtrier/dev/django/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/mtrier/dev/django/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/mtrier/dev/django/django/core/management/base.py", line 223, in execute
    output = self.handle(*args, **options)
  File "/Users/mtrier/.virtualenv/pcusa_cms/lib/python2.6/site-packages/south/management/commands/schemamigration.py", line 98, in handle
    old_orm = last_migration.orm(),
  File "/Users/mtrier/.virtualenv/pcusa_cms/lib/python2.6/site-packages/south/utils.py", line 62, in method
    value = function(self)
  File "/Users/mtrier/.virtualenv/pcusa_cms/lib/python2.6/site-packages/south/migration/base.py", line 418, in orm
    return FakeORM(self.migration_class(), self.app_label())
  File "/Users/mtrier/.virtualenv/pcusa_cms/lib/python2.6/site-packages/south/orm.py", line 46, in FakeORM
    _orm_cache[args] = _FakeORM(*args)  
  File "/Users/mtrier/.virtualenv/pcusa_cms/lib/python2.6/site-packages/south/orm.py", line 125, in __init__
    self.models[name] = self.make_model(app_label, model_name, data)
  File "/Users/mtrier/.virtualenv/pcusa_cms/lib/python2.6/site-packages/south/orm.py", line 344, in make_model
    fields,
  File "/Users/mtrier/dev/django/django/db/models/base.py", line 193, in __new__
    new_class._prepare()
  File "/Users/mtrier/dev/django/django/db/models/base.py", line 238, in _prepare
    signals.class_prepared.send(sender=cls)
  File "/Users/mtrier/dev/django/django/dispatch/dispatcher.py", line 166, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/Users/mtrier/dev/django/django/db/models/fields/related.py", line 82, in do_pending_lookups
    operation(field, sender, cls)
  File "/Users/mtrier/dev/django/django/db/models/fields/related.py", line 107, in resolve_related_class
    field.do_related_class(model, cls)
  File "/Users/mtrier/dev/django/django/db/models/fields/related.py", line 122, in do_related_class
    self.contribute_to_related_class(other, self.related)
  File "/Users/mtrier/dev/django/django/db/models/fields/related.py", line 1127, in contribute_to_related_class
    setattr(cls, related.get_accessor_name(), ManyRelatedObjectsDescriptor(related))
TypeError: attribute name must be string, not 'NoneType'

Attachments

Change History

comment:1 Changed 4 years ago by andrew

  • Status changed from new to infoneeded
  • Milestone changed from 0.7.1 to 0.7.2

What version of Django are you running? There have been some issues with M2Ms, South 0.7 and Django 1.2 beta, but they were fixed in Django trunk (they were more general issues than just us).

comment:2 Changed 4 years ago by andrew

  • Status changed from infoneeded to closed
  • Resolution set to worksforme

Closing as worksforme, no response.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.