-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
graph.create_edge object has no attribute '_id' #274
Comments
Do you have any example project to see how you implemented the OGM with Django? |
Here are my class structures
Here is a query that I use to fetch orientRecords and trying to create an edge
|
Thanks! Im struggling with the connection settings for orient. How did you set up your settings.py file? |
What is the error that you get?
…On Tue, Aug 14, 2018, 2:49 PM Tom Kennedy ***@***.***> wrote:
Thanks!
Im struggling with the connection settings for orient. How did you set up
your settings.py file?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#274 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABOgiBpsh9svx8ZYmoYTlqnnzwtc1vK5ks5uQpYpgaJpZM4VsS_A>
.
|
I am not at the stage of getting an error. I am new to Django and I am struggling to set up the connections to the database. Is it possible to share a sample of how to configure this? |
The graph.create_edge command expects objects that are subclasses of vertex, and not raw OrientRecords. For your code, one way to use create_edge would be along the following lines graph.create_edge(Friend, graph.get_element(prakash._rid), graph.get_element(brian._rid)) However, I would suggest to modify your code so that you use the OGM exclusively and do no mix low-level queries with the OGM unless absolutely necessary. from pyorient.ogm import Graph, Config
from pyorient.ogm.declarative import declarative_node, declarative_relationship
from pyorient.serializations import OrientSerialization
Node = declarative_node()
Relationship = declarative_relationship()
class Person(Node):
element_type = 'Person'
element_plural = 'Persons'
id = String(unique = True)
name = String()
class Friend(Relationship):
label = 'Friend'
graph = Graph(Config.from_url('<db_url>','<uname>', '<pass>', initial_drop=False,
serialization_type=OrientSerialization.Binary))
# If the classes already exists in your db schema, use include instead of create_all
# which will be a lot faster.
# Even if the classes do not exist, you only need to run create_all the first time after
# adding any additional classes above. Use graph.include once the classes are
# created in your db
graph.create_all(Node.registry)
graph.create_all(Relationship.registry)
# graph.include(Node.registry)
# graph.include(Relationship.registry)
prakash = graph.Persons.create(name='Prakash', id='1')
brian = graph.Persons.create(name='Brian', id='2')
prakash2 = graph.Persons.query(name='Prakash').first()
brian2 = graph.Persons.query(name='Brian').first()
graph.Friend.create(prakash, brian)
# graph.Friend.create(prakash2, brian2) # Same as above |
Hey,
I just signed the petition "Nitin Gadkari: Ban the honking in India unless
absolutely Necessary !!" and wanted to see if you could help by adding your
name.
Our goal is to reach 100 signatures and we need more support. You can read
more and sign the petition here:
http://chng.it/xxdV9V9CRR
Thanks!
Prakash
|
I don't like raw queries. So I'm trying to create an edge using
graph.create_edge(Friend, orientRecord1, orientRecord2)
But I get AttributeError: 'OrientRecord' object has no attribute '_id'
because orientRecord does not have an _id in it. What am I doing wrong?
The text was updated successfully, but these errors were encountered: