On 22/01/2020 5:32 am, Soumen Khatua wrote:
Hi Folks,

I want to start my primary key from saome random number like: 7777(onwards)
but not from 1.

I wonder why?

How I can do that in django?

If I really had to do that I would adjust the relevant sequence manually via PGAdmin.

Otherwise, I would have to invent a single use method which only operates if the id is 1 on creation of a model instance. That method would have to generate the random number and execute raw SQL to update the sequence and then update the id to match.

Another way might be to continuously create and delete records until the id was the same as your random number.

Good luck

Mike


Thank you in advance

Regards,
Soumen
--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6Wbrnst2pAkdCZp%2B2jd4etsYGE_o%2BBO%2BAc85TPeyG92a3A%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAPUw6Wbrnst2pAkdCZp%2B2jd4etsYGE_o%2BBO%2BAc85TPeyG92a3A%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a96faf9f-96c6-f490-7e2d-9221ab53bda3%40dewhirst.com.au.

Reply via email to