[Answer]-"DoesNotExist: ContentType matching query does not exist" only happens occassionally

1👍

One problem might be that you are comparing 2 instances with eachother, while these should be the same in Django since Django caches them, that is not a guarantee.

Not sure how/where the source_content_type comes from, but I would recommend this instead:

return isinstance(obj, contesttype)

As for the original problem, do you have a stacktrace? This error seems a bit strange.

Are you sure that Contest isn’t being overwritten somewhere in the scope?
Contest could be overwritten by other code in the module, the most likely suspect in that case would be a global Contest but that doesn’t appear to be the case here.

[edit]

Thanks to the stacktrace the problem is a bit clearer.

This part specifically shows that it’s going wrong in the obj.source_content_type part:

return obj.source_content_type == contesttype

I think that some object doesn’t have an existing source_content_type anymore.

👤Wolph

Leave a comment