Skip to content
/ django Public

Fixed #21175 -- Abstract base model class fires class_prepared signal#1916

Closed
famousfilm wants to merge 1 commit intodjango:masterfrom
famousfilm:ticket_21175
Closed

Fixed #21175 -- Abstract base model class fires class_prepared signal#1916
famousfilm wants to merge 1 commit intodjango:masterfrom
famousfilm:ticket_21175

Conversation

@famousfilm
Copy link
Copy Markdown
Contributor

Created test for class_prepared signal and reconditioned abstract
base model class to send class_prepared signal.

Created test for class_prepared signal and reconditioned abstract
base model class to send class_prepared signal.
@timgraham
Copy link
Copy Markdown
Member

This needs to be updated to apply cleanly (signals_regress tests have been consolidated).

It wouldn't hurt to mention this in the 1.8 release notes as well as add a note in https://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.class_prepared with a versionchanged:: 1.8 note.

There's also a failing test:

======================================================================
ERROR: test_foreign_key_to_abstract_model (invalid_models_tests.test_relative_fields.RelativeFieldTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tim/code/django/tests/invalid_models_tests/test_relative_fields.py", line 272, in test_foreign_key_to_abstract_model
    class AbstractModel(models.Model):
  File "/home/tim/code/django/django/db/models/base.py", line 286, in __new__
    signals.class_prepared.send(sender=new_class)
  File "/home/tim/code/django/django/dispatch/dispatcher.py", line 198, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/home/tim/code/django/django/db/models/fields/related.py", line 92, in do_pending_lookups
    operation(field, sender, cls)
  File "/home/tim/code/django/django/db/models/fields/related.py", line 270, in resolve_related_class
    field.do_related_class(model, cls)
  File "/home/tim/code/django/django/db/models/fields/related.py", line 306, in do_related_class
    self.set_attributes_from_rel()
  File "/home/tim/code/django/django/db/models/fields/related.py", line 303, in set_attributes_from_rel
    self.rel.set_field_name()
  File "/home/tim/code/django/django/db/models/fields/related.py", line 1257, in set_field_name
    self.field_name = self.field_name or self.to._meta.pk.name
AttributeError: 'NoneType' object has no attribute 'name'

@timgraham
Copy link
Copy Markdown
Member

Please open a new PR if you can update it, thanks.

@timgraham timgraham closed this May 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants