List Info

Thread: Overriding Default Primary Key Type?




Overriding Default Primary Key Type?
country flaguser name
United States
2007-11-06 17:02:29
Howdy Folks!

I've got a new project coming up that will generate
gazillions (that's
a technical term for a whole lot) of objects for certain
objects in
the model.

Is it possible to get Django to use a really large integer
type for
the automatically-generated primary key, like a serial or
bigserial in
postgresql?

Many thanks!

--gordon


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Overriding Default Primary Key Type?
country flaguser name
Australia
2007-11-06 20:37:12
On Tue, 2007-11-06 at 15:02 -0800, gordyt wrote:
> Howdy Folks!
> 
> I've got a new project coming up that will generate
gazillions (that's
> a technical term for a whole lot) of objects for
certain objects in
> the model.
> 
> Is it possible to get Django to use a really large
integer type for
> the automatically-generated primary key, like a serial
or bigserial in
> postgresql?

You can't change the underlying data type for the
automatically
generated primary key without changing Django's source.

So your choices are either to write a custom field or, more
easily,
manually alter the type of the primary key column after the
table has
been created (see
http://www.djangoproject.com/doc
umentation/model-api/#providing-initial-sql-data ).


Regards,
Malcolm

-- 
The cost of feathers has risen; even down is up! 
http://www.pointy-s
tick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Overriding Default Primary Key Type?
country flaguser name
United States
2007-11-07 08:23:55
Malcolm thanks very much.  This is a great idea:

> You can't change the underlying data type for the
automatically
> generated primary key without changing Django's
source.
>
> So your choices are either to write a custom field or,
more easily,
> manually alter the type of the primary key column after
the table has
> been created (seehttp://www.djangoproject.com/documentati
on/model-api/#providing-initi...).

I knew about being able to populate the database using the
method that
you linked to but never even considered  using that very
same method
to customize the schema.   Just wonderful!

--gordon


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )