question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Self referencing model

See original GitHub issue

Hello and thx for your lib,

I’d like to self-reference a model, but I’m not sure how to do it as I’m quite new to Python, what I do is:

class Player(Document):
    created_on = DateTimeField(default=datetime.now, db_field='d')
    name = StringField(required=True, db_field='n')

Player.friends = ListField(ReferenceField(Player))

But I get an AttributeError: 'NoneType' object has no attribute '_type' in python3.6/site-packages/graphene_mongo/converter.py

Am I doing it wrong or is it not possible?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
abawchencommented, Feb 25, 2018

@mehdiym: It’s a good point!

Graphene-Mongo does not support list of self-reference yet, and I am working on it now. Hope I can get back to you soon.

0reactions
mehdiymcommented, Mar 1, 2018

Wow, you did it fast, thank you very much. I’ll try that soon (it’s a personal project on my spare time, for now anyway)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Self-reference - Wikipedia
Self -reference occurs in natural or formal languages when a sentence, idea or formula refers to itself. The reference may be expressed either ......
Read more >
Self-Reference - Stanford Encyclopedia of Philosophy
In the context of language, self-reference is used to denote a statement that refers to itself or its own referent. The most famous...
Read more >
4. How to include a self-referencing ForeignKey in a model
Self -referencing foreign keys are used to model nested relationships or recursive relationships. They work similar to how One to Many relationships. But...
Read more >
Django Models self reference - python - Stack Overflow
I need to build a Django Model in which it refers to itself (a list of the same Model type within each instance...
Read more >
Different scenarios with Excel self referencing IF statements
Self referencing IF statements allow you to present the results of multiple scenarios regardless of the individual scenario being run in the model....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found