#8576: Multiple AutoFields in a model
-------------------------------------+-------------------------------------
Reporter: honeyman | Owner: nobody
Type: Uncategorized | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: multiple autofield | Triage Stage: Design
| decision needed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by logikonabstractions):
* ui_ux: => 0
* type: => Uncategorized
* severity: => Normal
* easy: => 0
Comment:
Know this is closed, but again just to provide perspective.
I could really have used this feature actually. I have a project with
existing data where they use as an ID an auto-increment (just like
Django's default id). However, they also use a different no_header.
Sometimes they create revision on their object, so basically their db ends
up looking like this:
id no_header suite
1 1 0
2 2 0
3 1 1
4 3 0
......
So essentially, the no_header is an auto-increment, that only increments
on the creation of new objects (with suite=0). If an object undergo some
specific operation, then its no_header remains the same, but suite += 1.
Which means that the no_header ends up running "behind" the id field, but
it still needs to be an auto-increment. Of course I can override save() &
do all that business there, but it would still be so much simpler to just
have 2 auto-increment fields. IMO this is a conception flaw in the
database backends - e.g there isn't an obvious reason to limit auto
increment to a single field, if a separate attributes allows specifying
what is a primary key. But I digress. Mostly wanted to illustrate a use
case.
--
Ticket URL: <https://code.djangoproject.com/ticket/8576#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.7ebb2291250e63570175501e88ffc7d5%40djangoproject.com.