Comments (15)
Please create a pull request with failing test.
from django-tastypie-mongoengine.
yep, trying to find where it bugs with my best friend pdb, and if i succeed you'll have a pull request with a fix :D
from django-tastypie-mongoengine.
No no. You can also just make a pull request with a test which fails. And then I can also look.
from django-tastypie-mongoengine.
ok as you want, but since I need this to be fixed asap, I'll investigate too
from django-tastypie-mongoengine.
OK. So yes. You can create pull request with test. And then later on augment it with another commit with a fix. :-)
from django-tastypie-mongoengine.
done :)
btw, is there any support for DateTimeField ? (I can't see any document with a mongoengine.DateTimeField in documents.py)
from django-tastypie-mongoengine.
Yes, that one should be automatically available in resource.
from django-tastypie-mongoengine.
okay, I have something that fails, so I'll do another pull request.
For the first problem, I identified the cause :
in File tastypie_mongoengine.resources.py, line 475:
def obj_get(self, request=None, **kwargs):
# MongoEngine exceptions are separate from Django exceptions, we combine them here
try:
return super(MongoEngineResource, self).obj_get(request, **kwargs)
In the returned function, tastypie does a query on the documents, and uses filter(**kwargs)
on the queryset. And kwargs
contains resource_uri
, so that fails. A quick fix for me would be inserting kwargs.pop('resource_uri', None)
, but maybe this can be inserted upstream.
from django-tastypie-mongoengine.
You are doing invalid REST request.
from django-tastypie-mongoengine.
hum why is that ? could you explain a little more ?
from django-tastypie-mongoengine.
See the test I fixed.
from django-tastypie-mongoengine.
ok thanks for your help. Btw, my request was not that invalid. If I remove 'put'
from the ExporterResource.allowed_method
, the problem does not occur and everything goes well. Anyway, thanks for your help and your plugin 👍
from django-tastypie-mongoengine.
That's semi-normal. :-)
To be user friendly, you can specify referenced document by any unique combination of fields (like id). But on the other hand you can also in-place create a referenced document by specifying values. And then there is another user friendly thing: if there is some additional field in the request which is not in the document, it is ignored. Sometimes it can be not so intuitive how this interacts. :-) resource_uri
is not a real field so when it tries to do a query it fails with error above. If you would remove resource_uri
but leave other two fields, it should work. On the other hand, if it tries to create a new referenced document, it ignores resource_uri
and just creates a new embedded document. So I am not so sure "problem does not occur" really happens. Probably it creates another referenced document, it does not reference the one you want.
This happens when you want to be user friendly and resolve ambiguities. :-)
from django-tastypie-mongoengine.
wow thanks for the explanation. I'll check that it does not create another document and that it does exactly what I want :-)
from django-tastypie-mongoengine.
OK, maybe that auto-creation does not really work always. :-)
from django-tastypie-mongoengine.
Related Issues (20)
- Support for Django 2.2
- Not compatible with QuerySetNoCache() HOT 1
- Python3 support? HOT 2
- Introspect mongoengine fields HOT 3
- Help me please. Embedded polymorphic HOT 3
- Problem with PUT and _id HOT 1
- Relase 0.4.6 HOT 1
- How can I implement token based authentication and authorization. HOT 1
- Upgrade to newer MongoEngine version
- Infinite resource depth HOT 2
- thread unsafe problem
- DjangoAuthorization does not work! HOT 2
- def apply_authorization_limits not working
- AssertionError: delete:{ ... request.body ... } HOT 1
- Cannot upgrade to tastypie==0.13.1 HOT 4
- Query date range
- Error with recent mongoengine versions HOT 1
- AttributeError: 'QuerySet' object has no attribute 'model'
- Import/Reference error
- TypeError: Error when calling the metaclass bases HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-tastypie-mongoengine.