#33259: The `Model._meta.related_objects` is return different values between 
shell
and from the request
-------------------------------------+-------------------------------------
               Reporter:  Hop Duong  |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  3.0
  layer (models, ORM)                |       Keywords:  Model, Related
               Severity:  Normal     |  Objects
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33259>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/056.afa8b2e5cf0c6f6301e33b168b01a905%40djangoproject.com.

Reply via email to