Got it - thank you! This community is great :)
On Tuesday, January 13, 2015 at 11:31:19 PM UTC-8, Jani Tiainen wrote:
>
> Because sequence number was running number per "tenant" (in my case it
> was invoice type) that started from zero (0) at the beginning of the
> every year.
>
> You could use
Because sequence number was running number per "tenant" (in my case it
was invoice type) that started from zero (0) at the beginning of the
every year.
You could use max+1 as well but you should be aware that there is a
slim chance that there is race condition and you may end up having two
entitie
Thanks Jani, good to hear someone has gone down this road before. Since you
did it in code, is there a reason you kept a sequence value on Tenant
rather than using Widget.objects.aggregate(Max(Widget.sequence_value)) ? I
ask because for my app, Widget is actually just one of several cases where
I've done something similiar.
Only way to do that is that you need to upkeep that tenant sequence_id manually,
So doing something like:
class Tenant(models.Model):
name = models.CharField(max_length=50)
sequence_value = models.IntegerField()
and in a code:
tenant = Tenant.object.get(id
I'm building a multi-tenant application with a data model that simplifies
to:
class Tenant(models.Model):
name = models.CharField(max_length=50)
class Widget(models.Model):
owner = models.ForeignKey(Tenant)
sequence_id =
I want Widget.sequence_id to work like an AutoField (that is
5 matches
Mail list logo