Opened 3 years ago
Closed 3 years ago
#33259 closed Bug (needsinfo)
Model._meta.related_objects returns different values in shell and from the request.
Reported by: | Hop Duong | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.0 |
Severity: | Normal | Keywords: | Model, Related Objects |
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'm implementing caching for the Model and generating the cache key by the Model related objects.
class CacheModel(models.Model): @classmethod def get_model_related_fields(cls): return cls._meta.related_objects
I have noticed that this method returns different values when I run from the Django shell
and from the request. For example:
- From the shell
(<OneToOneRel: ai_api.leadextradata>, <ManyToOneRel: ai_api.leadsubitv>, <ManyToOneRel: ai_api.attachment>, <ManyToOneRel: ai_api.leadnote>, <ManyToOneRel: ai_api.sharingcandidate>, <OneToOneRel: ai_api.employmentdata>, <OneToOneRel: ai_api.leadshortcodekeyword>, <OneToOneRel: ai_api.leadschedulingsettings>, <OneToOneRel: ai_api.employeeonboarding>, <ManyToOneRel: ai_api.leadschedulemessage>, <OneToOneRel: ai_api.itvteam>, <ManyToOneRel: ai_kb.clienttrainingmessage>, <OneToOneRel: ai_reminders.convoreminderaudit>, <ManyToOneRel: ai_campaign.campaigncontact>, <ManyToOneRel: ai_ratings.ratingconversation>, <ManyToOneRel: ai_ratings.ratingresponse>, <ManyToOneRel: ai_event.eventcandidate>, <ManyToOneRel: ai_event.eventcandidatecheckin>, <OneToOneRel: ai_event.eventitvlead>, <OneToOneRel: ai_event.eventregistration>, <OneToOneRel: ai_event.eventregistrationschedulingsettings>, <ManyToOneRel: ai_journeys.leadjourneyprogress>, <ManyToOneRel: ai_jobs.appliedjob>, <ManyToOneRel: ai_alerts.leadwatcher>, <ManyToOneRel: ai_conversation_flows.leadconvoflow>, <ManyToOneRel: ai_conversation_flows.leadconvostage>, <ManyToOneRel: ai_meeting.meeting>, <ManyToOneRel: ai_interview_prep.itvprepcandidate>, <ManyToOneRel: ai_recorded_interview.recordeditvcandidate>, <ManyToOneRel: ai_candidate_attributes.candidateattributes>, <ManyToOneRel: ai_cms.dynamiccontentcandidate>, <OneToOneRel: ai_candidate_profile.previousapplication>, <ManyToOneRel: ai_candidate_profile.previousapplication>, <ManyToOneRel: ai_conversations.conversationstage>, <ManyToOneRel: ai_conversations.leadsatisfycondition>, <ManyToOneRel: ai_conversations.leadvalidanswer>)
- From the request
(<OneToOneRel: ai_api.leadextradata>, <ManyToOneRel: ai_api.leadsubitv>, <ManyToOneRel: ai_api.attachment>, <ManyToOneRel: ai_api.leadnote>, <ManyToOneRel: ai_api.sharingcandidate>, <OneToOneRel: ai_api.employmentdata>, <OneToOneRel: ai_api.leadshortcodekeyword>, <OneToOneRel: ai_api.leadschedulingsettings>, <OneToOneRel: ai_api.employeeonboarding>, <ManyToOneRel: ai_api.leadschedulemessage>, <OneToOneRel: ai_api.itvteam>, <ManyToOneRel: ai_kb.clienttrainingmessage>, <OneToOneRel: ai_reminders.convoreminderaudit>, <ManyToOneRel: ai_campaign.campaigncontact>, <ManyToOneRel: ai_ratings.ratingconversation>, <ManyToOneRel: ai_ratings.ratingresponse>, <ManyToOneRel: ai_event.eventcandidate>, <ManyToOneRel: ai_event.eventcandidatecheckin>, <OneToOneRel: ai_event.eventitvlead>, <OneToOneRel: ai_event.eventregistration>, <OneToOneRel: ai_event.eventregistrationschedulingsettings>, <ManyToOneRel: ai_journeys.leadjourneyprogress>, <ManyToOneRel: ai_jobs.appliedjob>, <ManyToOneRel: ai_alerts.leadwatcher>, <ManyToOneRel: ai_conversation_flows.leadconvoflow>, <ManyToOneRel: ai_conversation_flows.leadconvostage>, <ManyToOneRel: ai_meeting.meeting>, <ManyToOneRel: ai_interview_prep.itvprepcandidate>, <ManyToOneRel: ai_recorded_interview.recordeditvcandidate>, <ManyToOneRel: ai_candidate_attributes.candidateattributes>, <ManyToOneRel: ai_cms.dynamiccontentcandidate>, <OneToOneRel: ai_candidate_profile.previousapplication>, <ManyToOneRel: ai_candidate_profile.previousapplication>, <ManyToOneRel: ai_conversations.conversationstage>, <ManyToOneRel: ai_conversations.leadsatisfycondition>, <ManyToOneRel: ai_conversations.leadvalidanswer>, <ManyToOneRel: ai_cms.intentcmsresponselogs>)
We have one more model <ManyToOneRel: ai_cms.intentcmsresponselogs>
in the request.
Change History (2)
comment:1 by , 3 years ago
comment:2 by , 3 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Summary: | The `Model._meta.related_objects` is return different values between shell and from the request → Model._meta.related_objects returns different values in shell and from the request. |
Also, Django 3.0 is no longer supported so you need to reproduce this issue with Django's main
branch.
Note:
See TracTickets
for help on using tickets.
Hi, you'll have to debug the issue and explain why Django is at fault or at least provide some minimal code to reproduce the issue.