Example:

Company has many Tickets
Tickets have a PK, as well as a "number".
Each Ticket's "number" should be the highest prior "number" for a
Ticket with the same Company

Ticket: pk: 1, number: 1, company: XYZ
Ticket: pk: 2, number: 1, company: Acme
Ticket: pk: 1, number: 2, company: XYZ

unique_together=(("number", "company"),)  # number is not unique
itself.

How should I handle this non-sense?


Confusing, convoluted, in-depth (sort of) explanation:

I have a model that sets the value of one of it's fields in the save()
method. It does this by reading the value of another field, and using
that value to calculate the value based on how many instances there
are with the same value in the other field (Basically an auto field
that increments with regards to a foreign key). The field that save()
sets is a unique field. This means that if 2 people on other sides of
the globe hit "submit" at the same time, the number of instances with
"other field"s value will be the same (e.g. 500). Then save() will
make self.number = 501, causing an IntegrityError for which ever one
takes longer to finish. How can I get around this? Or, better yet: How
should I do this instead?


Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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