wlanslovenija / django-tastypie-mongoengine

MongoEngine support for django-tastypie.
Other
73 stars 59 forks source link

imposed kwargs in ObjectId field #22

Closed yakxxx closed 11 years ago

yakxxx commented 12 years ago

I believe that intention of the author was to make some values given in kwarg have their defaults. But what he actually did is he imposed this values and made them impossible to change.

What i wanted to do in my Resource is to map '_id' field to 'id' field. I do this:

id = fields.ObjectId(attribute='_id', readonly=False, null=True)

But readonly and null args are ignored.

mitar commented 12 years ago

Can you please make a test which fail without this patch and pass with it?

mitar commented 11 years ago

ID's should be changed through REST interface. URIs should be immutable. So this was on purpose made read-only. Do you have an use case where this is not so?

mitar commented 11 years ago

Otherwise it seems Tastypie does not set readonly on primary keys, so we will also not force it here, just map attributes options by default (so ids will get by default unique flag and so on, but not readonly).