Utilities that make tastypie taste better.
The perfect counterpart to django-tastypie.
django-whippedcream provides a few mixins and utilities that I’ve used to make my life with tastypie easier.
Tested using django-tastypie>0.12, Django>1.7, and Python 2.7 and >3.4
django-tastypie, of course. Also pytz if you want to use the DateTimeSerializer.
This is a simple addition to the DateTimeField that removes milliseconds from the field. This is useful if you don’t want to provide that level of accuracy, but also if your database engine doesn’t store that level of accuracy (MySQL).
from whippedcream.fields import DateTimeField class MyResource(Resource): dt = DateTimeField('dt', normalize=True)
This mixin class can be added to any resource where you may want to access a serialized (JSON) version in any of your regular python code. It basically implements this pattern:
from whippedcream.mixins import PyAccessMixin class MyResource(MyAccessMixin, Resource): pass # elsewhere... result = MyResource().obj_to_simple(request, obj)