Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for 0.14 mongoengine #100

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
),
zip_safe = False,
install_requires = (
'Django>=1.5',
'Django>=1.4',
'django-tastypie>=0.9.12',
'mongoengine>=0.8.1,<0.8.2',
'mongoengine>=0.8.1',
'python-dateutil>=2.1',
'lxml',
'defusedxml',
Expand All @@ -47,9 +47,9 @@
),
test_suite = 'tests.runtests.runtests',
tests_require = (
'Django>=1.5',
'Django>=1.4',
'django-tastypie>=0.9.12',
'mongoengine>=0.8.1,<0.8.2',
'mongoengine>=0.8.1',
'python-dateutil>=2.1',
'lxml',
'defusedxml',
Expand Down
10 changes: 7 additions & 3 deletions tastypie_mongoengine/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ def dispatch(self, request_type, request, **kwargs):
the_method = request.method.lower()

if not request.body:
assert the_method not in ('put', 'post', 'patch'), the_method
assert the_method not in ('put', 'post', 'patch', 'delete'), the_method
return super(MongoEngineResource, self).dispatch(request_type, request, **kwargs)

assert the_method in ('put', 'post', 'patch'), the_method + ":" + request.body
assert the_method in ('put', 'post', 'patch', 'delete'), the_method + ":" + request.body

return self._wrap_request(request, lambda: super(MongoEngineResource, self).dispatch(request_type, request, **kwargs))

Expand Down Expand Up @@ -717,12 +717,16 @@ def get_fields(cls, fields=None, excludes=None):
api_field_class = cls.api_field_from_mongo_field(f)

primary_key = f.primary_key or name == getattr(cls._meta, 'id_field', 'id')

help_text = None
if hasattr(f,'help_text'):
help_text = f.help_text

kwargs = {
'attribute': name,
'unique': f.unique or primary_key,
'null': not f.required and not primary_key,
'help_text': f.help_text,
'help_text': help_text,
}

# If field is not required, it does not matter if set default value,
Expand Down