wpjunior / django-mongotools Goto Github PK
View Code? Open in Web Editor NEWDjango ClassViews, Forms for mongoengine support
Django ClassViews, Forms for mongoengine support
Complete implementation of mongoengine-based forms should include validation for mongoengine.EmbeddedDocumentField.
As I saw from the source, now EmbeddedDocuments are just skipped, am I right?
Hi
it seems that filefield doesn't work, i mean when i use such a field, it can't save in gridfs ?
is it normal ?
traces are :
Exception Type: AttributeError
Exception Value: 'InMemoryUploadedFile' object has no attribute 'grid_id'
/virtual-env/lib/python2.7/site-packages/mongoengine/fields.py in validate
return None
def to_python(self, value):
if value is not None:
return GridFSProxy(value)
def validate(self, value):
if value.grid_id is not None: # HERE THE ISSUE
assert isinstance(value, GridFSProxy)
assert isinstance(value.grid_id, pymongo.objectid.ObjectId)
def clean(self, oid):
if oid in EMPTY_VALUES and not self.required:
return None
try:
if self.coerce != int:
oid = ObjectId(value)
oid = super(ReferenceField, self).clean(oid)
queryset = self.queryset.clone()
obj = queryset.get(id=oid)
except (TypeError, InvalidId, self.queryset._document.DoesNotExist):
raise forms.ValidationError(self.error_messages['invalid_choice'] % {'value':value})
return obj
It throws exception:
Stacktrace (most recent call last):
File "django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "django/views/generic/base.py", line 48, in view
return self.dispatch(request, *args, **kwargs)
File "django/views/generic/base.py", line 69, in dispatch
return handler(request, *args, **kwargs)
File "constructor/apps/admin/views.py", line 25, in post
next = super(ChangelogMixin, self).post(request, *args, **kwargs)
File "mongotools/views/__init__.py", line 255, in post
return super(BaseUpdateView, self).post(request, *args, **kwargs)
File "django/views/generic/edit.py", line 137, in post
if form.is_valid():
File "django/forms/forms.py", line 124, in is_valid
return self.is_bound and not bool(self.errors)
File "django/forms/forms.py", line 115, in _get_errors
self.full_clean()
File "django/forms/forms.py", line 270, in full_clean
self._clean_fields()
File "django/forms/forms.py", line 287, in _clean_fields
value = field.clean(value)
File "mongotools/forms/utils.py", line 23, in inner_validate
value = old_clean(value)
File "mongotools/forms/fields.py", line 93, in clean
oid = ObjectId(value)
I guess In pymongo 2.2 there is not supported
No module named objectid
mongotools/forms/fields.py:4: from pymongo.objectid import ObjectId
There is no mongoengine.queryset.QuerySet._clone
but there is mongoengine.queryset.QuerySet.clone
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.