If you post the relevant part of your code in http://dpaste.com/ will be
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 Vasconcelos85 8767.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 Vasconcelos
85 8767.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.

Reply via email to