Somehow I have itworking without any custom managers or querysets. The last issue was fixed by importing simplejson instead of json.
Thanks for all the help On Oct 23, 5:05 pm, "dr.phil" <dr.p...@allergyct.com> wrote: > I narrowed down the error. Strang thing is this works in a shell but > not in my app. > > import datetime > from django.utils import simplejson as json > from django.core.serializers.json import DjangoJSONEncoder > > queryset = {"sColums" : "time", "aaDAta" : "[(datetime.datetime(2011, > 10, 19, 17, 18, 2))]"} > json.dumps(queryset, cls = DjangoJSONEcoder) > > ? This last statement fails in the app but not in a shell ? > > On Oct 23, 10:03 am, Casey Greene <csgre...@princeton.edu> wrote: > > > > > > > > > What is the error that that function gives you? It may be possible to > > just fix that function. > > > Casey > > > On 10/23/2011 07:42 AM, dr.phil wrote: > > > > The reason for this exercise is to produce suitable output for the > > > jquery plugin datatables. I am trying to use the following code > > >http://rus.hk/django-data-parser-for-jquery-datatable/ > > > > There are no problems until I include a datetime field. Then > > > 'datatabilize' fails because it cannot jsonify a datetime object. > > > > Probably the easiest solution is to avoid this generic utility > > > function and build my own? > > > > On Oct 22, 11:15 pm, Pedro Vasconcelos<pe...@pedrorafa.com> wrote: > > >> If you post the relevant part of your code inhttp://dpaste.com/willbe > > >> more easy to help you! > > > >> On Saturday, October 22, 2011, dr.phil<dr.p...@allergyct.com> wrote: > > >>> Thank you for the response. I added a function to the model to convert > > >>> a datetime field into the needed format (def convert_time). Then I set > > >>> new_time = property(convert_time). If I iterate over the queryset I > > >>> can access each.new_time BUT I need the value in the queryset > > >>> (Model.objects.filter().values('new_time')). Unfortunately Iget an > > >>> attribute error. > > > >>> Thank you. > > > >>> On Oct 22, 2:10 pm, Pedro Vasconcelos<pe...@pedrorafa.com> wrote: > > >>>> Hello, > > > >>>> A possible solution is create a specific method in your model class to > > >>>> do > > >>>> this calculation. Take a look at: > > > >>https://docs.djangoproject.com/en/1.3/topics/db/models/#model-methods > > > >>>> If you only want to do this calculations to show it in templates you > > >>>> may > > >>>> consider creating a specific template custom tag/filters. > > > >>>> Regards, > > > >>>> On Sat, Oct 22, 2011 at 1:31 AM, dr.phil<dr.p...@allergyct.com> wrote: > > >>>>> Is this possible? I have a model that includes a datetime field. When > > >>>>> creating a queryset of this model, I want to include a calculated > > >>>>> field of the time difference (in hours:minutes compared to > > >>>>> datetime.now). > > > >>>>> Currently, when creating a queryset the datetime is included. I can > > >>>>> iterate through the queryset to calculate the time difference and > > >>>>> replace the value. HOWEVER, when I act on this queryset, the original > > >>>>> (with datetime oject) is used, not the new dictionary I created. > > > >>>>> Help is apppreciated. > > > >>>>> -- > > >>>>> You received this message because you are subscribed to the Google > > >> Groups > > >>>>> "Django users" group. > > >>>>> To post to this group, send email to django-users@googlegroups.com. > > >>>>> To unsubscribe from this group, send email to > > >>>>> django-users+unsubscr...@googlegroups.com. > > >>>>> For more options, visit this group at > > >>>>>http://groups.google.com/group/django-users?hl=en. > > > >>>> -- > > >>>> Pedro Vasconcelos858767.1843 > > >>>> ptronico (skype) > > > >>> -- > > >>> You received this message because you are subscribed to the Google > > >>> Groups > > > >> "Django users" group.> To post to this group, send email to > > >> django-users@googlegroups.com. > > >>> To unsubscribe from this group, send email to > > > >> django-users+unsubscr...@googlegroups.com.> For more options, visit > > >> this group at > > > >>http://groups.google.com/group/django-users?hl=en. > > > >> -- > > >> Pedro Vasconcelos858767.1843 > > >> ptronico (skype) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.