接受JSON格式,解析他并具有访问数据的终点(Django)
您好,我想问一下如何在Django中创建模型和API,该模型和API接受JSON格式,解析它,然后在某些端点中访问它。我想拥有[post] endpoint /import
它将接受数据并解析它们,[get] /delets/< name_of_the_model>
将从该记录列表中显示JSON文件基于模型的名称,最后/delet/< name_of_the_model>/< id>
显示所有显示所有来自JSON文件的确切记录的数据。我认为我可以使用模型/模型来管理事情,但我无法弄清楚如何使用JSON实施它。感谢您的帮助。
PS:大约有8个具有属性的不同变量(不知道在JSON中调用它是如何称呼的),如果我为每个变量创建模型,我不确定是否正确执行此操作。这就是为什么我认为导入JSON是一件大事,但不知道该怎么做。
编辑:我已将REST框架安装到Django。也许那可能是道路,但仍然不知道如何正确地做。找不到任何地方。
Hello I want to ask how can I create models and API in Django that accepts JSON format, parsing it and then access it in some of the endpoints. I want to have [POST] endpoint /import
which will accept the data and parse them, [GET] /detail/<name_of_the_model>
will show list of records from the JSON file based on the name of the model and finally /detail/<name_of_the_model>/<id>
which shows all the data for the exact record from the JSON file. I think I can manage things with the models/modelForms but I can't figure out how to implement it with JSON. Thanks for any help.
PS: There are like 8 different variables with attributes (don't know how is it called in JSON) and I'm not sure if I'm doing it right if I create model for each of the variables. That's why I think that import the JSON is such a big thing but don't know how to do it.
EDIT: I've installed REST Framework to Django. Maybe that could be the way, but still have no idea how to do it properly. Can't find it anywhere.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论