Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#28978 closed Uncategorized (invalid)

m2m_changed signal's "model" argument is acting wierd

Reported by: Dev Aggarwal Owned by: nobody
Component: Database layer (models, ORM) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I hace a signal for m2m changed defined like this

@receiver(signals.m2m_changed, sender=models.Exam.questions.through)
def exam_questions_change(sender, instance, action, reverse, model, pk_set, using, **kwargs):
    print(repr(model))
    print(model.___class___)
    print(isinstance(model, models.Question))

And it gives me the following output

<class 'App.models.Question'>
<class 'django.db.models.base.ModelBase'>
False

What is going on here?

Change History (4)

comment:1 by Dev Aggarwal, 6 years ago

Summary: Djano m2m changed signal model argument is acting wierdDjano m2m_changed signal's "model" argument is acting wierd

comment:2 by Ramiro Morales, 6 years ago

Resolution: needsinfo
Status: newclosed
Summary: Djano m2m_changed signal's "model" argument is acting wierdm2m_changed signal's "model" argument is acting wierd

We'll need more information to tell if there is some Django issue worth investigating here:

What do you expect to see in that model parameter?

And a description of the M2M model setup would be great. Bonus points if you can provide a minimal project showing the issue.

in reply to:  2 comment:3 by Dev Aggarwal, 6 years ago

Replying to Ramiro Morales:

We'll need more information to tell if there is some Django issue worth investigating here:

What do you expect to see in that model parameter?

And a description of the M2M model setup would be great. Bonus points if you can provide a minimal project showing the issue.

Thanks for the reply.

I figured out what the problem was. I thought that model was an instance but it was the actual class of my model

doing this produced the required behavior :)

>> model == models.Question
True

comment:5 by Simon Charette, 6 years ago

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