2009/9/22 Michael Anckaert <[email protected]>:
>
> Hello everyone,
>
> I'm sure this is something that has been done before, I just can't
> figure out (or google) how to do it.
>
> I want to create PK's on a model that are in the form of 2009001,
> 2009002, 2009003, etc. Simple creating a model method that appends the
> year is not an option because I need models from 2010 to start with
> 2010001, 2010002, etc.
>
> Is there an elegant automatic solution or am I stuck with manually
> creating the PK?
>
> Kind regards,
> Michael
After building the model and runing syncdb, log into the database and do:
SELECT setval('my_pk_seq', 2009001);
where 'my_pk_seq' is the name of the sequence for the primary key of
the table in question.
HTH,
Tim Bowden
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---