Am 10.01.2012 20:46, schrieb Ian Clelland:

This is possible -- there was some discussion on this list about it just a few days ago. If you tell Django that another field is the actual primary key, then it will not assume that there is an 'id' column (which is good, because otherwise it will try to include that in any SELECT statements that it issues).
Seems I should read more often the list, then I wouldnt have missed that one.


As long as you consider this table to be essentially read-only, and you don't try to use the ORM to create any records in it, then you shouldn't have any problems with this. As specific measures:

- Don't try to create records with Model.objects.create() or Model.objects.get_or_create() - If you have to retrieve records, use filter() rather than get, if you can't ever assume uniqueness - Similarly, if you have to update records, use update() rather than save().

It sounds like you want to use aggregate queries on this table anyway, so you (hopefully) shouldn't run into any issues.
Yep that fits from the orm side it is only reading to aggregate statistics from a table holding history data, I like the orm style way easier to write/manage than raw queries hence my question, the inserts/deletes are handled lowlevel without django.

And cheers for the answer gave me the motivation to try it out in the near future, currently I only still got that "primary key" to not break the orm, removing it would free up quite some not needed space if it works.

Oh, and don't register this model with the admin; most of that framework is built around the idea of rows uniquely addressable by their primary key.

--
Regards,
Ian Clelland
<clell...@gmail.com <mailto:clell...@gmail.com>>
--
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.

--
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