Opened 12 months ago

Closed 12 months ago

Last modified 12 months 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 Changed 12 months ago by Dev Aggarwal

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

comment:2 Changed 12 months ago by Ramiro Morales

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.

comment:3 in reply to:  2 Changed 12 months ago by Dev Aggarwal

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 Changed 12 months ago by Simon Charette

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