Re: Created & updated date/time in models
On Sun, Aug 12, 2012 at 12:06 PM, Melvyn Sopacua <m.r.sopacua@gmail.com> wrote:
> On 8-8-2012 23:02, Lachlan Musicman wrote:
>
>> From what I can see, the admin interface already keeps this data for
>> each object (exception: no create_date for data imported via fixtures
>> apparently).
>
> Three options:
> 1) Add the fields you want to each model
> 2) Bypass django and use triggers to populate a separate table, this can
> be installed as custom SQL [1].
> 3) Implement 2) in django using generic foreign keys [2]. This is
> similar to how the admin is doing it, except that you would have to
> connect a global post_save (and pre_delete?) signal and ignore the
> signal if it applies to the "statistics collecting model". The overhead
> will be noticeable.
>
>> In an effort to reduce duplicating data, how would I go about getting
>> at that data from within my model's view?
>
> For option 1) it should be obvious.
> For option 3) by resolving the content type
> Option 2) requires raw SQL [3].
Bingo, perfect answer - thanks
(number 1 it is)
cheers
L.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home