没有 Neo4Django 的 Django 和 Neo4j [英] Django and Neo4j without Neo4Django

查看:13
本文介绍了没有 Neo4Django 的 Django 和 Neo4j的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Neo4j(以及 Postgres)构建一个 Django 应用程序,我发现这个 Django 集成名为 neo4django,我想知道是否可以只使用 neo4restclient,例如,不使用 Neo4django 有什么缺点?仅使用 neo4-rest-client 是否会给我更大的灵活性?当我使用 Neo4Django 创建模型时,似乎对图形数据库和关系数据库建模之间没有区别.我错过了什么吗?

I'm build a Django app with Neo4j (along with Postgres), I found this Django integration called neo4django, I was wondering if it's possible to use neo4restclient only, like, what would be the disadvantages of not using Neo4django? Does using neo4-rest-client only, give me more flexibility? When I was creating my models with Neo4Django, it seemed that there is no difference between modeling a graph db and relational db. Am I missing anything?

谢谢!

推荐答案

你绝对可以继续使用 neo4j-rest-client 或 py2neo,而无需使用 neo4django.同样,您可以随时使用任何其他数据库驱动程序,使用 Django、任何 REST 客户端等.

You can absolutely go ahead with neo4j-rest-client or py2neo, without using neo4django. In the same way, you can use any other database driver you'd like any time using Django, any REST client, etc.

你会失去什么?模型 DSL、内置查询(例如,Person.objects.filter(name="Mohamed"))、内置索引以及其背后的 Lucene、Gremlin 和 Cypher.有些事情会容易得多 - 例如在节点上设置任意属性 - 但您需要了解有关 Neo4j 工作原理的更多信息.

What'll you lose? The model DSL, the built-in querying (eg, Person.objects.filter(name="Mohamed")), the built-in indexing, and the Lucene, Gremlin and Cypher behind that. Some things will be much easier- like setting an arbitrary property on a node- but you'll need to learn more about how Neo4j works.

您还将丢失一些 Django 提供的与 neo4django 一起使用的快捷方式,例如 get_object_or_404() 和一些与查询集一起使用的基于类的视图.

You'll also lose some of the shortcuts Django provides that work with neo4django, like get_object_or_404() and some of the class-based views that work with querysets.

你会得到什么?对数据库的绝对权力,以及更容易调整数据库性能的时间.尽管neo4django 不像Python 领域中的一些传统ORM 那样是一个优秀的库,但在功能与提供的易用性之间的权衡是相似的.

What'll you gain? Absolute power over the DB, and an easier time tweaking DB performance. Though neo4django isn't nearly as good a lib as some traditional ORMs in the Python sphere, the trade-off of power vs provided ease is similar.

也就是说,两者可以协同工作——您可以随时从 neo4django 下拉到底层 REST 客户端节点和关系.只需使用 model_instance.node 从模型中获取底层的 neo4j-rest-client 节点对象,并使用 from neo4django.db import connection 来获取包装好的 neo4j-rest-clientGraphDatabase.

That said, the two can work together- you can drop down from neo4django to the underlying REST client nodes and relationships anytime. Just use model_instance.node to get the underlying neo4j-rest-client node object from a model, and from neo4django.db import connection to get a wrapped neo4j-rest-client GraphDatabase.

关于您是否遗漏了什么:neo4django 的编写是为了重用一个强大的开发人员界面——Django ORM——所以它应该类似于为 Postgres 编写模型.我过去曾写过一篇关于那种奇怪感觉的文章.我认为部分问题可能是该库没有突出图形术语新的对图形感兴趣的开发人员所期望的(例如遍历和模式匹配),而是在 Django 查询服装中使用这些技术.

On whether you're missing something: neo4django was written to re-use a powerful developer interface- the Django ORM- so it should feel similar to writing models for Postgres. I've written a bit about that odd feeling in the past. I think part of the problem might be that the lib doesn't highlight the graph terminology new graph-interested devs expect- like traversals and pattern matching- and instead dresses those techniques in Django query clothing.

我喜欢你的想法,或者知道你希望图书馆做但它没有做的任何事情:)祝你好运!

I'd love your thoughts, or to know anything you'd like the library to do that it isn't doing :) Good luck!

这篇关于没有 Neo4Django 的 Django 和 Neo4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆