简体   繁体   English

Django微服务互通的最佳方式是什么?

[英]What is the best way for Django microservices intercommunication?

I have a django microservice: M1 with admin page having fields:我有一个 Django 微服务:M1,管理页面有以下字段:

[link to field11] | [链接到field11] | [link to field 21] [链接到字段 21]

I have another django microservice: M2 with admin page having fields:我有另一个 Django 微服务:M2,管理页面有以下字段:

field11 | 11 | field12 |字段12 | field13 |字段13 | field14 |字段14 | field 15第 15 场

I have another django microservice: M3 with admin page having fields:我有另一个 Django 微服务:M3,管理页面有以下字段:

field21 | field21 | field22 | field22 | field23 | field23 | field24 | field24 | field 25第 25 场

My requirement is to get all the fields of M2 and M3 into M1's admin page.我的要求是将 M2 和 M3 的所有字段都放入 M1 的管理页面。 What are the ways I can do this?我有哪些方法可以做到这一点? I do not want to add more fields into M1's model.我不想在 M1 的模型中添加更多字段。

One way is to do interservice communication or do a GET call.一种方法是进行服务间通信或进行 GET 调用。 What will be more feasible?什么会更可行?

You can try some thing like this,你可以试试这样的东西

class M2(models.Model):
    field = models.CharField(max_length=100)


class M3(models.Model):
    field = models.CharField(max_length=100)


class M1(M2, M3):
    field = models.CharField(max_length=100)

So will get the fields of M2, and M3 into the M1, Hope its helps you, if anything else please let me know.+所以将把 M2 和 M3 的字段放入 M1,希望它对你有帮助,如果还有什么请告诉我。+

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM