Gabriel [SGT] wrote:
On Fri, Apr 12, 2013 at 2:47 PM, Mike Doroshenko II
<mi...@tecknoquest.com> wrote:
In my attached models.py
Please, don't attach code, use a paste service or similar to view the
code online.

Ok, yeah I suppose that would save storage space and bandwidth considering the fact I have a few copied of the same email (From my sent folder and I'm getting some emails twice).

the time last modified on the latest object that has a foreign key to it.

So when I made a new document, in the admin interface I see April 11, 2013,
8:24 p.m. for the Created column and 2013-04-11 20:24:36.799167 for the Last
Modified column.

Also I can click to sort the results by Created date, but not by last
modified date.

I'm afraid any reason why it's different. Are you using your own ModelAdmin ?

class DocAdmin(admin.ModelAdmin):

    list_display = ['name','created','last_modified']

Additionally in the same file in the model method I am using a for-loop to
get the value for Last Modified. I imagine going through each object just to
pull the data from the last one isn't very efficient and pretty redundant. I
tried to just pull the last object directly but am getting an error:
I modified your code accordingly http://pastebin.com/7NisAVfN

be aware that if a 'Piece' matching that criteria doesn't exists, it
will raise a DoesNotExist exception, maybe you'll want to catch it.

psst ->> https://docs.djangoproject.com/en/dev/ref/models/querysets/
Hmm so it was caused by a Document with no pieces. The code you provided simply returned None for that one :)

Thanks,
Mike

--
Mike Doroshenko, Junior Sys Admin
TecKnoQuest Inc.
mi...@tecknoquest.com
www.tecknoquest.com

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to