Re: Django generate unique sequence for each organisation in a SaaS app

2009-09-16 Thread Michael Manfre
You can do this without a stored procedure, but it will require two db queries. Create a custom field with an overridden pre_save that fetches the last RecordNum for the org and returns the next in the sequence. You'll want an index on org and recordnum. class AutoRecordNumberField(models.Intege

Django generate unique sequence for each organisation in a SaaS app

2009-09-15 Thread Sid
I'm working on a django SaaS app, which hosts data for multiple organisations. Each record in a table has a unique RecordNumber. I could use autofield to give each record a unique incrementing Id automatically, but that is globally unique. As in org1 might have say, RecordNum=1 or 2 or 7 etc and