Coder Social home page Coder Social logo

Comments (6)

mitar avatar mitar commented on July 17, 2024

Where in you API have you defined reference fields for django-tastypie-mongoengine? Reference fields are not (cannot be) automatically mapped.

from django-tastypie-mongoengine.

Seraf avatar Seraf commented on July 17, 2024

Oh thanks, I tried that before but didn't get it to work.
Now I have a partial result :
With :

class WorkspaceResource(mongoresources.MongoEngineResource):
    user = fields.ReferenceField(to='web.lisa.api.UserResource', attribute='id', full=True)

It results with :

{
  "error": [
    "ValidationError (Workspace:lisa) (Invalid Object ID: ['id'] Field is required: ['user'])"
  ]
}

Do you have an idea how could I map the user id please ? My UserResource just map the mongoengine User object.

Sorry to annoy you with a stupid question like this, I understood it isn't tastypie-mongoengine related issue, but I think it lacks a little documentation around the user object.

Thanks a lot for your time !

from django-tastypie-mongoengine.

mitar avatar mitar commented on July 17, 2024

I don't understand what you would like to map? If you have in your workspace document attribute "id", then on your API resource you also should have field "id". You just have to specify it manually, because there is no way that the system would know which is the related resource.

So what do you believe this line:

user = fields.ReferenceField(to='web.lisa.api.UserResource', attribute='id', full=True)

does?

from django-tastypie-mongoengine.

mitar avatar mitar commented on July 17, 2024

BTW, you can always check tests for more examples as well.

from django-tastypie-mongoengine.

Seraf avatar Seraf commented on July 17, 2024

Hello, thanks for your tips.
I fixed it with this : Seraf/LISA@bd644ca
I tried this by looking your unit tests. Don't know if it's the right way to go, but it works.

Thanks a lot !

from django-tastypie-mongoengine.

mitar avatar mitar commented on July 17, 2024

Great.

from django-tastypie-mongoengine.

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.