Compilation of request(Django orm)



  • There are models: UserProjectNews

    User related Project a lot of connections.

    News One to many.

    I can't figure out a request to get all the news from all the projects that the user has signed and dispersed them over time.


  • QA Engineer

    If I understood the structure correctly, you could make such a request:
    Project.objects.filter(user=current_user).prefetch_related('news')

    Each facility queryset It'll be an attribute. news with the news list. To respond more to the model code.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2