Code Monkey home page Code Monkey logo

Comments (10)

jschrewe avatar jschrewe commented on June 23, 2024

Could you post the document that produces the error? My guess is that there is an error in the first if in get_inline_instances.

from django-mongoadmin.

justincy avatar justincy commented on June 23, 2024

I'm getting a similar error, except mine days "NoneType' object has no attribute 'document_type'". Perhaps bad data is causing this.

My fix was to change the if statement at line 346:

            if hasattr(f, 'field') and f.field:
                embedded_document = f.field.document_type
            elif hasattr(f, 'document_type'):
                embedded_document = f.document_type
            else:
                continue

from django-mongoadmin.

jschrewe avatar jschrewe commented on June 23, 2024

Could you give me the definition of the document that causes this error? Because I don't see how and why an EmbeddedDocumentField can be None. But it may well be I'm overlooking something here. And while your fix certainly works, I guess it could lead to missing InlineAdmins for some documents.

from django-mongoadmin.

justincy avatar justincy commented on June 23, 2024

What's the easiest way to view a the contents of a document? Printing just tells me what class it is.

from django-mongoadmin.

jschrewe avatar jschrewe commented on June 23, 2024

print obj.__dict__ prints out all the attributes of the object. Mongoengine keeps all the data in the obj.data (or something similar) dict. None is usually assigned to data that is defined on the document schema, but not stored in the database.

from django-mongoadmin.

justincy avatar justincy commented on June 23, 2024
{'_data': {'motherID': None, 'families': [], 'tags': [], 'personal': None, 'fatherID': None, 'childrenIDs': [], 'missing': None, 'api_id': None, 'events': None, 'note': None, 'cached': False, 'api': None, 'relation': None, 'user': None, 'spouseID': None, 'synced': datetime.datetime(2012, 2, 15, 11, 47, 49, 316099), 'parents': [], 'ordinances': None, 'id': None}, '_initialised': True}

from django-mongoadmin.

jschrewe avatar jschrewe commented on June 23, 2024

Thanks for the data. Sadly it helps little without the schema. My attempts at recreating the error have so far failed miserably.

from django-mongoadmin.

justincy avatar justincy commented on June 23, 2024
class Person(Document):
    user = ReferenceField('User',required=True)
    # valid api values are "nfs"
    api = StringField(max_length=50,required=True)
    api_id = StringField(max_length=10,required=True)
    cached = BooleanField(default=False)
    synced = DateTimeField(default=datetime.datetime.now)
    personal = EmbeddedDocumentField(Personal)
    events = EmbeddedDocumentField(Events)
    ordinances = EmbeddedDocumentField(Ordinances)
    families = ListField(EmbeddedDocumentField(Family))
    parents = ListField(EmbeddedDocumentField(Parents))
    missing = EmbeddedDocumentField(Missing)
    relation = StringField()
    motherID = StringField(max_length=10)
    fatherID = StringField(max_length=10)
    # spouse and children should eventually be kept as part of a family
    spouseID = StringField(max_length=10)
    childrenIDs = ListField()
    tags = ListField()
    note = StringField()

from django-mongoadmin.

justincy avatar justincy commented on June 23, 2024

I found more documents that cause the problem:

'NoneType' object has no attribute 'document_type'
{'admin_site': <mongoadmin.sites.AdminSite object at 0x2770c50>, 'model': <class 'family.models.Person'>, 'document': <class 'family.models.Person'>, 'inline_instances': [<mongoadmin.options.EmbeddedStackedDocumentAdmin object at 0x2e945d0>], 'opts': <mongodbforms.documentoptions.DocumentMetaWrapper object at 0x2e944d0>}

'NoneType' object has no attribute 'document_type'
{'admin_site': <mongoadmin.sites.AdminSite object at 0x2770c50>, 'model': <class 'family.models.Person'>, 'document': <class 'family.models.Person'>, 'inline_instances': [<mongoadmin.options.EmbeddedStackedDocumentAdmin object at 0x2e945d0>, <mongoadmin.options.EmbeddedStackedDocumentAdmin object at 0x2e947d0>], 'opts': <mongodbforms.documentoptions.DocumentMetaWrapper object at 0x2e944d0>}

Are these documents that the admin module uses?

from django-mongoadmin.

jschrewe avatar jschrewe commented on June 23, 2024

@justincy Mongoadmin does not have any documents. Your data appears to be the admin object itself.

I've added your fix in the last commit, so that should close that.

from django-mongoadmin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.