Closed eelkeh closed 11 years ago
Because we have tests for this I am not sure if this really does not work. Probably tastypie or mongoengine again upgraded their versions and break something. Can you try tests and if they work for you? If they do, then please augment them with another test case which fails. If test fail, try older versions of tastypie or mongoengine until they work. And then try your example again.
I checked and tests work for me. So please make a pull request with a new test which fails.
(I just pushed new version to fix one other tests issue.)
Thanks a lot for the quick responses, this can be closed. My issue was that I didn't register my urls on a TastyPie Api instance, this is apparently necessary when generating schema's. Before I did something like this:
article_resource = api.ArticleResource()
...
and include article_resource.urls, but in order for schema's to work properly, you need an Api instance.
v1_api = Api(api_name='1')
v1_api.register(api.ArticleResource())
and include those urls, v1_api.urls
Of course. :-) Only registered resources are accessible through URLs.
Well, actually this works fine (apart from schema generation):
article_resource = api.ArticleResource()
urlpatterns = patterns(r'^api/', include(article_resource.urls))
Ehm. And where have you found this documented as supported/official approach? Of course you can find ways things work if you manually extract variables from objects, but then don't complain when things don't work. :-) Have you read Tastypie documentation? Do they have such example there?
It's literally lifted from an example in the Tastypie documentation: http://django-tastypie.readthedocs.org/en/latest/tutorial.html#hooking-up-the-resource-s
Interesting. Does schema work in pure Tastypie when it is registered like that?
Not sure, haven't looked into it extensively, but in tastypie-mongoengine it seems to break on ReferenceFields when it assumes an api_name property somewhere, as in: Reverse for 'api_get_schema' with arguments '()' and keyword arguments '{'api_name': None, 'resource_name': 'publications'}' not found Not sure if this is worth chasing down though, let me know if I can be of any help though, thanks!
Can you please check what happens with Tastypie when schema has a reference field there?
I'll have a look next week!
When my resource class is polymorphic, the /schema url fails, something like this:
The schema for the article resource returns:
When I remove the polymorphic attribute, it works as expected.